Skip to content

Commit

Permalink
Changes for Revision 1: Updates to code (new spatial specificity anal…
Browse files Browse the repository at this point in the history
…yses) and manuscript (more specific discussion, related to transferability of approach to other systems), README
  • Loading branch information
mrikasper committed Jun 4, 2021
1 parent 99492f4 commit cb31389
Show file tree
Hide file tree
Showing 32 changed files with 3,054 additions and 760 deletions.
18 changes: 12 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
[submodule "Code/Toolboxes/tnufmri"]
path = Code/Toolboxes/tnufmri
url = git@tnurepository.ethz.ch:lkasper/tnufmri.git
[submodule "Code/Toolboxes/UniQC"]
path = Code/Toolboxes/UniQC
url = git@gitlab.ethz.ch:uniqc/uniqc-code.git
[submodule "Code/Toolboxes/UniQC-Tasks"]
path = Code/Toolboxes/UniQC-Tasks
url = git@gitlab.ethz.ch:uniqc/uniqc-tasks.git
[submodule "Code/Toolboxes/export_fig"]
path = Code/Toolboxes/export_fig
url = https://github.com/altmany/export_fig.git
[submodule "Code/Toolboxes/PhysIO"]
path = Code/Toolboxes/PhysIO
url = git@tnurepository.ethz.ch:physio/physio-public.git
[submodule "Code/Toolboxes/spm12"]
path = Code/Toolboxes/spm12
url = git@tnurepository.ethz.ch:SPM/spm12.git
[submodule "Code/Toolboxes/TAPAS"]
path = Code/Toolboxes/TAPAS
url = https://github.com/translationalneuromodeling/tapas.git
[submodule "Code/Toolboxes/export_fig"]
path = Code/Toolboxes/export_fig
url = https://github.com/altmany/export_fig.git
[submodule "Code/Toolboxes/ismrmrd"]
path = Code/Toolboxes/ismrmrd
url = https://github.com/ismrmrd/ismrmrd.git
2 changes: 2 additions & 0 deletions Code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.asv
*.m~
Empty file added Code/.gitkeep
Empty file.
18 changes: 10 additions & 8 deletions Code/Analysis/spifi_compute_summary.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ function spifi_compute_summary(details)
% spifi_compute_summary
%
% See also

% Author: Lars Kasper
% Created: 2019-06-19
% Copyright (C) 2019 Institute for Biomedical Engineering
% University of Zurich and ETH Zurich
%
% This file is part of the TAPAS UniQC Toolbox, which is released
% under the terms of the GNU General Public License (GPL), version 3.
% under the terms of the GNU General Public License (GPL), version 3.
% You can redistribute it and/or modify it under the terms of the GPL
% (either version 3 or, at your option, any later version).
% For further details, see the file COPYING or
Expand Down Expand Up @@ -51,9 +51,11 @@ function spifi_compute_summary(details)
copyfile(details.glm.tcon, details.summary.tcon);


% copy warped and unbiased stuff
copyfile(details.preproc.anat.warp2mni, details.summary.anat.warp2mni);
copyfile(details.preproc.func.biascorrected, details.summary.func.biascorrected);
copyfile(details.preproc.func.warp2mni, details.summary.func.warp2mni);
copyfile(details.glm.warp2mni.tcon_differential1, ...
details.summary.glm.warp2mni.tcon_differential1);
% copy warped and unbiased stuff, don't mind, if it does not exist
try
copyfile(details.preproc.anat.warp2mni, details.summary.anat.warp2mni);
copyfile(details.preproc.func.biascorrected, details.summary.func.biascorrected);
copyfile(details.preproc.func.warp2mni, details.summary.func.warp2mni);
copyfile(details.glm.warp2mni.tcon_differential1, ...
details.summary.glm.warp2mni.tcon_differential1);
end
2 changes: 1 addition & 1 deletion Code/Analysis/spifi_coreg_anat_to_func.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
% University of Zurich and ETH Zurich

X = MrImageSpm4D(coregOpts.source);
meanX = mean(X);
meanX = mean(X, 't');
meanX.save('fileName', coregOpts.mean);

Y = MrImageSpm4D(coregOpts.ref);
Expand Down
10 changes: 8 additions & 2 deletions Code/Analysis/spifi_run_segment_anat.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function matlabbatch = spifi_run_segment_anat(fileAnat, templateBatch, savedBatch)
function matlabbatch = spifi_run_segment_anat(fileAnat, templateBatch, savedBatch, biasFwhm)
% Segments anatomical image and saves bias-corrected version, as well as
% bias field and tissue probability maps
%
% matlabbatch = spifi_run_segment_anat(fileAnat, templateBatch, savedBatch)
% matlabbatch = spifi_run_segment_anat(fileAnat, templateBatch, savedBatch, biasFwhm)
%
% IN
%
Expand All @@ -25,8 +25,14 @@
% For further details, see the file COPYING or
% <http://www.gnu.org/licenses/>.
%

if nargin < 4
biasFwhm = 60;
end

run(templateBatch);
matlabbatch{1}.spm.spatial.preproc.channel.vols{1} = fileAnat;
matlabbatch{1}.spm.spatial.preproc.channel.biasfwhm = biasFwhm;
tnufmri_convert_batch_mat_to_m(matlabbatch, savedBatch);
spm_jobman('interactive', matlabbatch);
spm_jobman('run', matlabbatch);
2 changes: 1 addition & 1 deletion Code/Analysis/spifi_warp2mni_func_anat.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
matlabbatch{1}.spm.spatial.normalise.write.subj.def{1} = ...
opts.forwardDeformationField;
matlabbatch{1}.spm.spatial.normalise.write.subj.resample = ...
opts.source;
opts.source(isfile(opts.source)); % only warp existing files
tnufmri_convert_batch_mat_to_m(matlabbatch, opts.saveBatch)
spm_jobman('interactive', matlabbatch);
spm_jobman('run', matlabbatch);
44 changes: 44 additions & 0 deletions Code/Attic/check_quality.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function qcImages = check_quality(fileNameNifti)
% Computes Quality Control measures for nifti time series and plots the
% relevant ones
%
% qcImages = check_quality(fileNameNifti)
%
% IN
%
% OUT
% qcImages cell(nImages,1) of MrImage, relevant quality control
% images, e.g., mean/tsnr/maxdiffabs etc.
%
% EXAMPLE
% check_quality
%
% See also
%
% Author: Lars Kasper
% Created: 2018-05-23
% Copyright (C) 2018 Institute for Biomedical Engineering
% University of Zurich and ETH Zurich
%
% This file is part of the TAPAS UniQC Toolbox, which is released
% under the terms of the GNU General Public License (GPL), version 3.
% You can redistribute it and/or modify it under the terms of the GPL
% (either version 3 or, at your option, any later version).
% For further details, see the file COPYING or
% <http://www.gnu.org/licenses/>.
%
% $Id: new_function2.m 354 2013-12-02 22:21:41Z kasperla $

Y = MrImage(fileNameNifti);

Y.mean.plot()
Y.std.plot()
Y.snr.plot()

plot(abs(Y-mean(Y)), 'useSlider', 'true');

plot(image2k(Y-mean(Y)), 'useSlider', 'true');



qcImages{1} = Y;
39 changes: 39 additions & 0 deletions Code/Attic/glm_uniqc.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
%% model specification
TR = 3.128
physio_path = ...
fileExplicitMask = '';% fullfile(data_path, 'masks', 'brain_mask.nii');

% timing in seconds
data.glm.timingUnits = 'secs';
% repetition time
data.glm.repetitionTime = TR;
% model derivatives
data.glm.hrfDerivatives = [0 0]; %[1 1];
% noise model FAST
data.glm.serialCorrelations = 'FAST';
% add conditions
% specify block length first
block_length = 18;
% specify first condition
first_condition = [1 5 7 11 13 17];
first_condition_onsets = first_condition*block_length;
% specify second condition
second_condition = [2 4 8 10 14 16];
second_condition_onsets = second_condition*block_length;
% add to glm
data.glm.conditions.names = {'simple', 'complex'};
data.glm.conditions.onsets = {second_condition_onsets, first_condition_onsets};
% add durations
data.glm.conditions.durations = {block_length, block_length};
% add confound regressors
confound_regressors = load(fullfile(physio_path,'multiple_regressors.txt'));
data.glm.regressors.other = confound_regressors;
% add an explicit mask
data.glm.explicitMasking = fileExplicitMask;
% turn of inplicit masking threshold;
data.glm.maskingThreshold = -Inf;

% compute stat images
data.compute_stat_images;
% estimate
data.specify_and_estimate_1st_level;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
function fhArray = create_figure_readout_duration_t2star()
%Compares full spiral readout to cropped one (1mm, 37ms) to show effect of
%longer readout under T2*
%
% fhArray = create_figure_readout_duration_t2star()
%
% Note: This needs to run SPIFI_0007_MainReconstructImages of
% recon-scripts-spifi (git@tnurepository.ethz.ch:laymm/recon-scripts-spifi.git)
% at commit 8a79c10886f27fc83419d720ddf936f9cf026a69 before
%
% IN
%
% OUT
%
% EXAMPLE
% create_figure_readout_duration_t2star
%
% See also

% Author: Lars Kasper
% Created: 2020-06-18
% Copyright (C) 2020 Institute for Biomedical Engineering
% University of Zurich and ETH Zurich
%
% This file is part of the TAPAS UniQC Toolbox, which is released
% under the terms of the GNU General Public License (GPL), version 3.
% You can redistribute it and/or modify it under the terms of the GPL
% (either version 3 or, at your option, any later version).
% For further details, see the file COPYING or
% <http://www.gnu.org/licenses/>.
%

X = MrImage
X.read_data_from_graphics_handle(21)
Y = MrImage
Y.read_data_from_graphics_handle(14)
X.plot
Y.plot
plot(abs(X./max(X)-Y./max(Y)))
2 changes: 1 addition & 1 deletion Code/Representation/create_figure_spm_subject.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
zI(end-1:end), ...
'selectedSlices', figOptions.selectedSlice, ...
sharedParameters_tra{:}, ...
'nRows', 1);
'nRows', 4);
case 'sag'
%% sagittal plot
zI = resizedUnderlay.crop_all({'x', [100 100]}, Y(nFiles+[-1 0]));
Expand Down
Loading

0 comments on commit cb31389

Please sign in to comment.