Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brain_radius fix #29

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/analyses_v2
Binary file not shown.
Binary file modified bin/dcan_signal_processsing
Binary file not shown.
Binary file modified bin/filtered_movement_regressors
Binary file not shown.
3 changes: 2 additions & 1 deletion dcan_bold_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def interface(subject, output_folder, task=None, fd_threshold=None,
input_spec['movement_regressors'], str(repetition_time),
str(motion_filter_option), str(motion_filter_order),
str(band_stop_min), motion_filter_type, str(band_stop_min),
str(band_stop_max), filtered_movement_regressors]
str(band_stop_max), str(brain_radius), filtered_movement_regressors]

subprocess.call(cmd)
# update input movement regressors
Expand Down Expand Up @@ -530,6 +530,7 @@ def interface(subject, output_folder, task=None, fd_threshold=None,
'motion_filename': os.path.basename(
output_spec['output_motion_numbers']),
'skip_seconds': skip_seconds,
'brain_radius_in_mm': brain_radius,
'result_dir': output_spec['result_dir']
}
# write input json for matlab script
Expand Down
6 changes: 4 additions & 2 deletions matlab_code/dcan_signal_processing.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ function dcan_signal_processing(config_path)
motion_filename= conf_json.motion_filename;
skip_seconds= conf_json.skip_seconds;
result_dir= conf_json.result_dir;
brain_radius_in_mm = conf_json.brain_radius_in_mm
brain_radius_in_cm= brain_radius_in_mm * 0.1;
int_method= 'linear';
%silence warnings
warning('off', 'all')
Expand Down Expand Up @@ -64,14 +66,14 @@ function dcan_signal_processing(config_path)
%% read mov_reg and calculate Friston regressors
MR = dlmread(file_mov_reg);
MR = MR(:, [1 2 3 4 5 6]);
FR = make_friston_regressors(MR);
FR = make_friston_regressors(MR, brain_radius_in_cm);

%% Calculate residuals (regression)
[r, c] = size(X');
Rr = zeros(r,c);

%% Create FD.mat
FD = calc_FD_HCP(file_mov_reg);
FD = calc_FD_HCP(file_mov_reg, brain_radius_in_mm);
save([result_dir filesep 'FD.mat'], 'FD', '-v7')
txt_FD_file=[path_ex_sum filesep 'FD_' fMRIName '.txt'];
save(txt_FD_file, 'FD','-ascii')
Expand Down
8 changes: 5 additions & 3 deletions matlab_code/filtered_movement_regressors.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function filtered_movement_regressors(path_mov_reg, TR, filt_option, order, LP_freq_min, filt_type, fc_RR_min, fc_RR_max, output)
function filtered_movement_regressors(path_mov_reg, TR, filt_option, order, LP_freq_min, filt_type, fc_RR_min, fc_RR_max, brain_radius, output)
%% This function applies a low pas filter to the motion numbers and save it with a different number

% %% Input arguments
Expand All @@ -8,7 +8,8 @@ function filtered_movement_regressors(path_mov_reg, TR, filt_option, order, LP_f
% order order of the filter to be applied
% LP_freq_min Low pass frequency (in minutes) to be filtered
%% defaults
head_ratio_cm = 5;
% head_ratio_cm = 5;


%% when compiling comment out paths and uncomment this section
TR = str2num(TR);
Expand All @@ -17,6 +18,7 @@ function filtered_movement_regressors(path_mov_reg, TR, filt_option, order, LP_f
LP_freq_min = str2num(LP_freq_min);
fc_RR_min = str2num(fc_RR_min);
fc_RR_max = str2num(fc_RR_max);
head_ratio_cm = str2num(brain_radius) * 0.1;

%% filter design

Expand Down Expand Up @@ -83,7 +85,7 @@ function filtered_movement_regressors(path_mov_reg, TR, filt_option, order, LP_f
% Read motion numbers
file_mov_reg = [path_contents(i).folder filesep path_contents(i).name]; %-- for MATLAB USE
MR = dlmread(file_mov_reg);
MR_ld=make_friston_regressors(MR);%% Using this function to only get the linear displacements
MR_ld=make_friston_regressors(MR, head_ratio_cm);%% Using this function to only get the linear displacements
MR_ld=MR_ld(:,1:6);

switch filt_option
Expand Down