-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the package name from "whims" to "MRIreduce"
- Loading branch information
Jinyao Tian
committed
Sep 13, 2024
1 parent
b4696b0
commit 376def9
Showing
26 changed files
with
273 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ | |
"ascending": true | ||
} | ||
], | ||
"path": "~/Desktop/WHIMs/R" | ||
"path": "~/Desktop/MRIreduce" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
{ | ||
"left": { | ||
"splitterpos": 345, | ||
"splitterpos": 269, | ||
"topwindowstate": "NORMAL", | ||
"panelheight": 682, | ||
"windowheight": 720 | ||
"panelheight": 663, | ||
"windowheight": 701 | ||
}, | ||
"right": { | ||
"splitterpos": 373, | ||
"splitterpos": 79, | ||
"topwindowstate": "NORMAL", | ||
"panelheight": 682, | ||
"windowheight": 720 | ||
"panelheight": 663, | ||
"windowheight": 701 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
Package: whims | ||
Package: MRIreduce | ||
Type: Package | ||
Title: NeuroPartitioner: An R Package for ROI-Based Transformation of Neuroimages into High-Dimensional Data Frames | ||
Title: MRIreduce: An R Package for ROI-Based Transformation of Neuroimages into High-Dimensional Data Frames | ||
Version: 0.1.0 | ||
Authors@R: c( | ||
person("Joshua", "Milstein", email = "[email protected]", role = c("aut")), | ||
person("Jinyao", "Tian", email = "[email protected]", role = c("aut", "cre")) | ||
) | ||
Maintainer: Jinyao Tian <[email protected]>, Joshua Milstein <[email protected]> | ||
Description: NeuroPartitioner is an advanced R package designed to convert NIfTI format T1/FL neuroimages into structured, high-dimensional 2D data frames, focusing on region of interest (ROI) based processing. This package incorporates a key algorithm called ‘partition’, which offers a fast, flexible framework for agglomerative partitioning based on the Direct-Measure-Reduce approach. This method ensures that each reduced variable maintains a user-specified minimum level of information while being interpretable, as each maps uniquely to one variable in the reduced dataset. The ‘partition’ algorithm, detailed in Millstein et al. (2020), allows for customization in variable selection, measurement of information loss, and data reduction methods. NeuroPartitioner is indispensable for researchers requiring efficient, accurate preparation of neuroimaging data for detailed statistical analysis and machine learning applications, enhancing the interpretability and utility of neuroimaging studies. | ||
Description: MRIreduce is an advanced R package designed to convert NIfTI format T1/FL neuroimages into structured, high-dimensional 2D data frames, focusing on region of interest (ROI) based processing. This package incorporates a key algorithm called ‘partition’, which offers a fast, flexible framework for agglomerative partitioning based on the Direct-Measure-Reduce approach. This method ensures that each reduced variable maintains a user-specified minimum level of information while being interpretable, as each maps uniquely to one variable in the reduced dataset. The ‘partition’ algorithm, detailed in Millstein et al. (2020), allows for customization in variable selection, measurement of information loss, and data reduction methods. NeuroPartitioner is indispensable for researchers requiring efficient, accurate preparation of neuroimaging data for detailed statistical analysis and machine learning applications, enhancing the interpretability and utility of neuroimaging studies. | ||
License: MIT + file LICENSE | ||
Imports: | ||
Rcpp, | ||
|
@@ -35,4 +35,4 @@ Suggests: | |
knitr, | ||
rmarkdown | ||
VignetteBuilder: knitr | ||
URL: https://jtian123.github.io/WHIMs/ | ||
URL: https://github.com/jtian123/MRIreduce |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#' Map Reduced Feature Back to Brain Image Voxel Locations | ||
#' | ||
#' This function maps a given feature name to voxel locations by identifying the pattern in the feature name. | ||
#' If the feature name contains "reduced_var", it follows the format "Roi_module_reduced_var" and this indicates that it is a reduced feature. Otherwise, it follows | ||
#' the format "Roi_Vnumber", which is not a reduced feature by Partition. Based on the pattern, the function extracts the appropriate region of interest (ROI) and | ||
#' retrieves voxel locations from intensity data. | ||
#' | ||
#' @param feature_name String. A feature name. | ||
#' @param threshold a numeric between 0 and 1. The Partition threshold value applied to the data. | ||
#' @param main_dir String. The main directory containing the data files. | ||
#' | ||
#' @return A data frame containing the voxel locations (x,y,z Coordinates) corresponding to the extracted mapping column. | ||
#' | ||
#' @details | ||
#' Each voxel in a brain image corresponds to a specific feature, establishing a one-to-one mapping between a voxel and a feature. This relationship allows us | ||
#' to localize particular brain features to specific brain areas at the voxel level, enabling visualization of these features. However, after applying Super-Partition and Partition techniques, | ||
#' multiple brain features are aggregated into a single reduced feature as part of a data reduction process. The goal of the following function is to relate the reduced feature back to its component features, | ||
#' and subsequently identify the brain image voxels to which those component features are mapped. | ||
#' This function performs the following steps: | ||
#' | ||
#' 1. **Check Feature Name Format:** It first checks if the `feature_name` contains "reduced_var". If it does, the function assumes the format "Roi_module_reduced_var", otherwise it assumes the format "Roi_Vnumber". | ||
#' | ||
#' 2. **Extract ROI and Mapping Information:** | ||
#' - For the "Roi_module_reduced_var" format, the ROI and module number are extracted, and the corresponding partition file is read to retrieve the mapping vector. | ||
#' - For the "Roi_Vnumber" format, the `V` number is extracted from the feature name and used as the mapping vector. | ||
#' | ||
#' 3. **Extract Voxel Locations:** The mapping vector is then used to extract voxel locations from the intensity data. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' loc_df <- map_feature2_loc(feature_name = "inferior_frontal_gyrus_left_module4_reduced_var_13", threshold = 0.8, main_dir = "/path/to/data") | ||
#' } | ||
#' | ||
#' @export | ||
map_feature2_loc <- function(feature_name, threshold,main_dir) { | ||
if (grepl("reduced_var", feature_name)) { | ||
# Extract the ROI for the format "Roi_module_reduced_var" | ||
roi <- sub("_module.*", "", feature_name) # Remove everything after and including "_module" | ||
module = sub(".*module(\\d+).*", "\\1", feature_name) | ||
variable_name = sub(".*(reduced_var_\\d+).*", "\\1", feature_name) | ||
file_path = file.path(main_dir, "partition", roi, threshold, "map", paste0("Par_intensities_map_", module, ".rds")) | ||
df = readRDS(file_path) | ||
vec <- df[df$variable == variable_name, "mapping"][[1]] | ||
} else { | ||
# Extract the ROI for the format "Roi_Vnumber" | ||
roi <- sub("_V\\d+.*", "", feature_name) # Remove everything after and including "_V<number>" | ||
vec <- sub(".*(V\\d+).*", "\\1", feature_name) | ||
} | ||
|
||
# Extract voxel locations | ||
extract_mapping_voxel <- function(tind, roi, Cols) { | ||
file_name <- paste0("intensities_", roi, "_", tind,".rds") | ||
df <- readRDS(file.path(main_dir, "intensities", file_name)) | ||
locs <- df[1:3, Cols, drop = FALSE] | ||
return(locs) | ||
} | ||
load_required_data("eve_label_info_dataframe.RData", "whims") | ||
tind = lab_df[lab_df$text_label == roi, "integer_label"] | ||
# Extract the voxel locations | ||
loc_df <- extract_mapping_voxel(tind, roi, vec) | ||
return(loc_df) | ||
} | ||
|
||
##Test | ||
# feature_name = "inferior_frontal_gyrus_left_module11_reduced_var_5" | ||
# threshold = 0.8 | ||
# main_dir = '/Users/jinyaotian/Downloads/whims_test' | ||
# loc_df = map_feature2_loc(feature_name = feature_name, threshold = threshold, main_dir = main_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
url: https://jtian123.github.io/WHIMs/ | ||
url: https://jtian123.github.io/MRIreduce/ | ||
template: | ||
bootstrap: 5 | ||
bootswatch: cosmo # Using the Flatly theme from Bootswatch | ||
|
||
navbar: | ||
title: NeuroPartitioner | ||
title: MRIreduce | ||
left: | ||
- text: Home | ||
href: index.html | ||
- text: Get Started | ||
href: articles/NeuroPartitioner.html # Link directly to your vignette | ||
href: articles/MRIreduce.html # Link directly to your vignette | ||
- text: Reference | ||
href: reference/index.html | ||
right: | ||
- text: View on source code | ||
href: https://github.com/jtian123/WHIMs | ||
href: https://github.com/jtian123/MRIreduce | ||
icon: fab fa-github |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.