Skip to content

Commit

Permalink
New version of load_spm_pattern.m with improved 'single' flag handling.
Browse files Browse the repository at this point in the history
Revamped versions of unit_spm scripts
  • Loading branch information
Wildcarde committed Mar 19, 2010
1 parent c706cf7 commit 7618937
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 49 deletions.
10 changes: 7 additions & 3 deletions core/io/load_spm_pattern.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@

%% Create a volume structure
vol = spm_vol(filenames);
tmp_data = []; %#ok<NASGU>


%%%%%%%%%%%%%%%%%%%%%%
%sylvains contribution
Expand All @@ -132,8 +132,12 @@
end;

% allocate all at once to avoid reshaping iteratively
tmp_data = zeros(mSize, total_m);

tmp_data = []; %#ok<NASGU> This is necessary as the command is now wrapped in an if/else
if args.single
tmp_data = zeros(mSize, total_m,'single');
else
tmp_data = zeros(mSize, total_m);
end
total_m = 0;
%% end contribution
for h = 1:nFiles % start looping thru the files being used.
Expand Down
19 changes: 14 additions & 5 deletions tests/spm_test_omnibus.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
% DEFAULTS
% Before we get started we need to setup a single default.
defaults.fextension = '.nii';
defaults.single = 'false';
global single


args = propval(varargin,defaults);

Expand All @@ -44,6 +47,12 @@
fextension=defaults.fextension;
end

if (isfield(args,'single'))
single = args.single;
else
single = defaults.single;
end

%% Load up errs and warns so that they you know... work
errs = {};
warns = {};
Expand All @@ -54,19 +63,19 @@
%% Run Functional Tests One by One and populate errs/warns.

% run basic spm ana test
[errs{end+1} warns{end+1}] = unit_spm_ana('fextension',fextension);
[errs{end+1} warns{end+1}] = unit_spm_ana('fextension',fextension,'single',single);

% run the tutorial comparison
[errs{end+1} warns{end+1}] = unit_spm_afni_tutcompare('fextension',fextension);
[errs{end+1} warns{end+1}] = unit_spm_afni_tutcompare('fextension',fextension,'single',single);

% run afni compare
[errs{end+1} warns{end+1}] = unit_spm_ana_afnicompare('fextension',fextension);
[errs{end+1} warns{end+1}] = unit_spm_ana_afnicompare('fextension',fextension,'single',single);

% haxby data compare
[errs{end+1} warns{end+1}] = unit_spm_ana_haxby_dat_compare('fextension',fextension);
[errs{end+1} warns{end+1}] = unit_spm_ana_haxby_dat_compare('fextension',fextension,'single',single);

%cell array tests
[errs{end+1} warns{end+1}] = unit_spm_cellarrayfilename_load('fextension',fextension);
[errs{end+1} warns{end+1}] = unit_spm_cellarrayfilename_load('fextension',fextension,'single',single);


end
11 changes: 10 additions & 1 deletion tests/unit_spm_afni_tutcompare.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
% The afni data used in this test was created from the corresponding SPM
% test data using the afni 3dcopy command with no flags or special
% commands.

defaults.fextension = '';
defaults.single = false;
global single


args = propval(varargin,defaults);

Expand All @@ -43,6 +45,13 @@
fextension=defaults.fextension;
end

if (isfield(args,'single'))
single = args.single;
else
single = defaults.single;
disp('The tutorials have no support for the single command');
end

errs = {};
warns = {};

Expand Down
15 changes: 12 additions & 3 deletions tests/unit_spm_ana.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
% DEFAULTS
% Before we get started we need to setup a single default.
defaults.fextension = '';
defaults.single = false;
global single


args = propval(varargin,defaults);

Expand All @@ -56,6 +59,12 @@
fextension=defaults.fextension;
end

if (isfield(args,'single'))
single = args.single;
else
single = defaults.single;
end

errs = {};
warns = {};

Expand Down Expand Up @@ -185,15 +194,15 @@

% load the pattern the first time
% temp_subj_001=load_spm_pattern(temp_subj_001, 'ana_brain','spm_ana_mask',raw_source_filenames{n},'beta_defaults','true');
temp_subj_001=load_spm_pattern(temp_subj_001, 'ana_brain','spm_ana_mask',raw_source_filenames{n});
temp_subj_001=load_spm_pattern(temp_subj_001, 'ana_brain','spm_ana_mask',raw_source_filenames{n},'single',single);
%and write it back out.
write_to_spm(temp_subj_001,'pattern','ana_brain','output_filename',['testwork/utest_' num2str(n) '_' ],'padding',base_padding,'fextension',fextension);

% this happens due to the way files are saves the dest name
% would be valid if they weren't individual files.
%
% what does this comment mean???
temp_subj_002=load_spm_pattern(temp_subj_002, 'ana_brain','spm_ana_mask',['testwork/utest_' num2str(n) '_' fextension]);
temp_subj_002=load_spm_pattern(temp_subj_002, 'ana_brain','spm_ana_mask',['testwork/utest_' num2str(n) '_' fextension],'single',single);
data1 = get_mat(temp_subj_001,'pattern','ana_brain');

data2 = get_mat(temp_subj_002,'pattern','ana_brain');
Expand Down Expand Up @@ -235,7 +244,7 @@
index=num2str(i);
raw_filenames{i} = ['haxby8_r' index fextension];
end
subj = load_spm_pattern(subj,'epi','VT_category-selective',raw_filenames);
subj = load_spm_pattern(subj,'epi','VT_category-selective',raw_filenames,'single',single);
%keyboard;
write_to_spm(subj,'pattern','epi','output_filename','testwork/utest2_','padding',base_padding,'fextension',fextension);

Expand Down
15 changes: 12 additions & 3 deletions tests/unit_spm_ana_afnicompare.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
% DEFAULTS
% Before we get started we need to setup a single default.
defaults.fextension = '';
defaults.single = 'false';
global single


args = propval(varargin,defaults);

Expand All @@ -47,6 +50,12 @@
fextension=defaults.fextension;
end

if (isfield(args,'single'))
single = args.single;
else
single = defaults.single;
end

errs = {};
warns = {};

Expand Down Expand Up @@ -155,9 +164,9 @@


% load the pattern the first time
temp_subj_001=load_spm_pattern(temp_subj_001, 'ana_brain','spm_ana_mask',spm_file_names{n});

temp_subj_001=load_afni_pattern(temp_subj_001, 'afni_brain','spm_ana_mask',afni_file_names{n});
temp_subj_001=load_spm_pattern(temp_subj_001, 'ana_brain','spm_ana_mask',spm_file_names{n},'single',single);
%temp_subj_001=load_spm_pattern(temp_subj_001, 'ana_brain','spm_ana_mask',spm_file_names{n});
temp_subj_001=load_afni_pattern(temp_subj_001, 'afni_brain','spm_ana_mask',afni_file_names{n},'single',single);

data1 = get_mat(temp_subj_001,'pattern','ana_brain');

Expand Down
15 changes: 12 additions & 3 deletions tests/unit_spm_ana_haxby_dat_compare.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
% DEFAULTS
% Before we get started we need to setup a single default.
defaults.fextension = '';
defaults.single = 'false';
global single


args = propval(varargin,defaults);

Expand All @@ -29,6 +32,12 @@
fextension=defaults.fextension;
end

if (isfield(args,'single'))
single = args.single;
else
single = defaults.single;
end

errs = [];
warns = [];

Expand All @@ -47,16 +56,16 @@

write_to_spm(working_subj,'pattern','epi_z_anova_1','new_header','true','pathname','testwork','output_filename','anova_out','fextension',fextension);

working_subj=load_spm_pattern(working_subj,'epi_anova_compare','VT_category-selective',['testwork/anova_out' fextension]);
working_subj=load_spm_pattern(working_subj,'epi_anova_compare','VT_category-selective',['testwork/anova_out' fextension],'single',single);



mainpat = get_mat(working_subj,'pattern','epi_z_anova_1');

comparepat = get_mat(working_subj,'pattern','epi_anova_compare');

keyboard;
if ~isequal(mainpat,comparepat)
errs(end+1) = 'data does not compare properly, arbitrary header writeout failed.';
errs{end+1} = 'data does not compare properly, arbitrary header writeout failed. This is normal for the single true flag.';
end


Expand Down
Loading

0 comments on commit 7618937

Please sign in to comment.