-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into 'master'
Including the outlier censoring.
- Loading branch information
Showing
7 changed files
with
102 additions
and
7 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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
mccExcludedFiles.log | ||
readme.txt | ||
requiredMCRProducts.txt | ||
bin/ | ||
templates/parcellations/ | ||
*.asv | ||
*.nii | ||
*.mat | ||
._* |
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
Binary file not shown.
Binary file not shown.
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,27 @@ | ||
function output_removal_vector = outlier_censoring(wb_command, dtseries, input_removal_vector) | ||
|
||
outlier_removal_vector = zeros(size(input_removal_vector,1), size(input_removal_vector,2)); | ||
|
||
[status,cmdout] = system([wb_command ' -cifti-stats ' dtseries ' -reduce STDEV']); | ||
|
||
if status ~= 0 | ||
return | ||
end | ||
|
||
% parse standard deviation values | ||
stdevs = cell2mat(textscan(cmdout, '%f\n')); | ||
|
||
% find the kept frames | ||
input_idx = find(~input_removal_vector); | ||
|
||
% find outliers | ||
outlier_vector = isoutlier(stdevs(input_idx),'median'); | ||
|
||
% find indices of outliers within the kept frames | ||
outlier_idx = find(outlier_vector); | ||
|
||
% put the outlier flags into the outliers vector as ones (to censor) | ||
outlier_removal_vector( input_idx(outlier_idx) ) = 1; | ||
|
||
% convert outliers flags vector to a strict logical vector | ||
output_removal_vector = logical(outlier_removal_vector); |
37 changes: 37 additions & 0 deletions
37
matlab_code/framewise_displacement/subject_outliers_parse_BIDS.m
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,37 @@ | ||
function subject_outliers_parse_BIDS(wb_command,motion_data_file,dtseries,output_dir,output_prefix) | ||
% FD parsing Nipype wrapper pulling in list of motion files | ||
% Modified to read DVAR_pre_reg, DVAR_post_reg, and DVAR_post_all and store | ||
% values appropriately in the 51x51x3 cell array of structs | ||
% | ||
% All variables (skips, TR, CurrentDirectory) set within Nipype | ||
% Iterates over range of values from 0.1 to maximum of 0.5 FD threshold | ||
% Outputs to .mat file | ||
% FD_movement_files = {'motion_numbers0.txt', 'motion_numbers1.txt', 'motion_numbers2.txt'}; | ||
% FD_movement_files can be TXT or DAT files | ||
% varargin (brain_radius_in_mm) only needs to be provided for DAT file inputs | ||
|
||
load(motion_data_file); | ||
FD_range_max = motion_data{length(motion_data)}.FD_threshold; | ||
FD_range = 0:0.01:FD_range_max; | ||
|
||
for i = 1:length(motion_data) | ||
|
||
motion_data{i}.fd_removal = motion_data{i}.frame_removal; | ||
motion_data{i}.outlier_removal = double(outlier_censoring(wb_command, dtseries, motion_data{i}.frame_removal)); | ||
motion_data{i}.combined_removal = double(motion_data{i}.fd_removal | motion_data{i}.outlier_removal); | ||
|
||
motion_data{i}.fd_format_string = format_generator(motion_data{i}.fd_removal); | ||
motion_data{i}.outlier_format_string = format_generator(motion_data{i}.outlier_removal); | ||
motion_data{i}.combined_format_string = format_generator(motion_data{i}.combined_removal); | ||
|
||
motion_data{i}.remaining_fd_count = motion_data{i}.total_frame_count - sum(motion_data{i}.fd_removal); | ||
motion_data{i}.remaining_outlier_count = motion_data{i}.total_frame_count - sum(motion_data{i}.outlier_removal); | ||
motion_data{i}.remaining_combined_count = motion_data{i}.total_frame_count - sum(motion_data{i}.combined_removal); | ||
|
||
motion_data{i}.remaining_fd_seconds = motion_data{i}.remaining_fd_count * motion_data{i}.epi_TR; | ||
motion_data{i}.remaining_outlier_seconds = motion_data{i}.remaining_outlier_count * motion_data{i}.epi_TR; | ||
motion_data{i}.remaining_combined_seconds = motion_data{i}.remaining_combined_count * motion_data{i}.epi_TR; | ||
|
||
end | ||
|
||
save([output_dir filesep output_prefix '_outliers_power_2014_FD_only.mat'],'motion_data'); |
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