-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed error reported by S.magothr. (New Segment error).
- Loading branch information
1 parent
f599918
commit c5bb0d5
Showing
6 changed files
with
91 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function ea_checkforwardinv(options,forwardinv) | ||
|
||
switch forwardinv | ||
case 'forward' | ||
V=spm_vol([options.root,options.patientname,filesep,'y_ea_normparams.nii']); | ||
Vmni=spm_vol([options.earoot,'templates',filesep,'mni_hires.nii']); | ||
|
||
if ~isequal(V.dim,Vmni.dim) | ||
|
||
ea_redo_inv([options.root,options.patientname,filesep],options,'forward'); | ||
end | ||
case 'inverse' | ||
V=spm_vol([options.root,options.patientname,filesep,'y_ea_inv_normparams.nii']); | ||
Vanat=spm_vol([options.root,options.patientname,filesep,options.prefs.prenii_unnormalized]); | ||
if ~isequal(V.dim,Vanat.dim) | ||
ea_redo_inv([options.root,options.patientname,filesep],options,'inverse'); | ||
end | ||
end |
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,45 @@ | ||
function ea_generate_tpm | ||
function ea_generate_tpm(varargin) | ||
|
||
spmdir=[fileparts(which('spm')),filesep]; | ||
earoot=[fileparts(which('lead')),filesep]; | ||
if nargin | ||
earoot=varargin{1}.earoot; | ||
end | ||
|
||
switch spm('ver') | ||
case 'SPM8' | ||
copyfile([spmdir,'toolbox',filesep,'Seg',filesep,'TPM.nii'],[earoot,'templates',filesep,'TPM.nii']); | ||
copyfile([spmdir,'toolbox',filesep,'Seg',filesep,'TPM.nii'],[earoot,'templates',filesep,'TPM.nii']); | ||
case 'SPM12' | ||
copyfile([spmdir,'tpm',filesep,'TPM.nii'],[earoot,'templates',filesep,'TPM.nii']); | ||
copyfile([spmdir,'tpm',filesep,'TPM.nii'],[earoot,'templates',filesep,'TPM.nii']); | ||
end | ||
|
||
ea_reslice_nii([earoot,'templates',filesep,'TPM.nii'],[earoot,'templates',filesep,'TPM.nii'],[0.5 0.5 0.5],0,0,3); | ||
|
||
for tp=1:6 | ||
matlabbatch{1}.spm.util.imcalc.input = {[earoot,'templates',filesep,'mni_hires.nii'] | ||
[earoot,'templates',filesep,'TPM.nii,1'] | ||
[earoot,'templates',filesep,'TPM.nii,2'] | ||
[earoot,'templates',filesep,'TPM.nii,3'] | ||
[earoot,'templates',filesep,'TPM.nii,4'] | ||
[earoot,'templates',filesep,'TPM.nii,5'] | ||
[earoot,'templates',filesep,'TPM.nii,6']}; | ||
matlabbatch{1}.spm.util.imcalc.output = [earoot,'templates',filesep,'TPM_',num2str(tp),'.nii']; | ||
matlabbatch{1}.spm.util.imcalc.outdir = {''}; | ||
matlabbatch{1}.spm.util.imcalc.expression = ['i',num2str(tp+1)]; | ||
matlabbatch{1}.spm.util.imcalc.var = struct('name', {}, 'value', {}); | ||
matlabbatch{1}.spm.util.imcalc.options.dmtx = 0; | ||
matlabbatch{1}.spm.util.imcalc.options.mask = 0; | ||
matlabbatch{1}.spm.util.imcalc.options.interp = 1; | ||
matlabbatch{1}.spm.util.imcalc.options.dtype = 4; | ||
cfg_util('run',{matlabbatch}); | ||
fis{tp}=[earoot,'templates',filesep,'TPM_',num2str(tp),'.nii']; | ||
end | ||
clear matlabbatch | ||
matlabbatch{1}.spm.util.cat.vols = fis; | ||
matlabbatch{1}.spm.util.cat.name = [earoot,'templates',filesep,'TPM.nii']; | ||
matlabbatch{1}.spm.util.cat.dtype = 4; | ||
cfg_util('run',{matlabbatch}); | ||
|
||
for fi=1:length(fis) | ||
delete(fis{fi}); | ||
end | ||
delete([earoot,'templates',filesep,'TPM.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
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,6 +1,27 @@ | ||
function ea_redo_inv(directory,options) | ||
matlabbatch{1}.spm.util.defs.comp{1}.inv.comp{1}.def = {[directory,'y_ea_normparams.nii']}; | ||
matlabbatch{1}.spm.util.defs.comp{1}.inv.space = {[directory,options.prefs.prenii_unnormalized]}; | ||
matlabbatch{1}.spm.util.defs.out{1}.savedef.ofname = 'ea_inv_normparams.nii'; | ||
matlabbatch{1}.spm.util.defs.out{1}.savedef.savedir.saveusr = {directory}; | ||
spm_jobman('run',{matlabbatch}); | ||
function ea_redo_inv(varargin) | ||
directory=varargin{1}; | ||
options=varargin{2}; | ||
if nargin>2 | ||
forinv=varargin{3}; | ||
else | ||
forinv='inverse'; | ||
end | ||
switch forinv | ||
case 'inverse' | ||
matlabbatch{1}.spm.util.defs.comp{1}.inv.comp{1}.def = {[directory,'y_ea_normparams.nii']}; | ||
matlabbatch{1}.spm.util.defs.comp{1}.inv.space = {[directory,options.prefs.prenii_unnormalized]}; | ||
matlabbatch{1}.spm.util.defs.out{1}.savedef.ofname = 'ea_inv_normparams.nii'; | ||
matlabbatch{1}.spm.util.defs.out{1}.savedef.savedir.saveusr = {directory}; | ||
spm_jobman('run',{matlabbatch}); | ||
|
||
case 'forward' | ||
|
||
|
||
matlabbatch{1}.spm.util.defs.comp{1}.id.space = {[options.earoot,'templates',filesep,'mni_hires.nii']}; | ||
matlabbatch{1}.spm.util.defs.comp{1}.def = {[directory,'y_ea_normparams.nii']}; | ||
matlabbatch{1}.spm.util.defs.out{1}.savedef.ofname = 'ea_normparams.nii'; | ||
matlabbatch{1}.spm.util.defs.out{1}.savedef.savedir.saveusr = {directory}; | ||
spm_jobman('run',{matlabbatch}); | ||
|
||
|
||
end |
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