Skip to content

Commit

Permalink
mh fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Aug 31, 2021
1 parent 542a68d commit 39e65b6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
36 changes: 18 additions & 18 deletions src/defaults/Mapping.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
%
% - mapping : (n X 1) structure with the following fiels
%
% - prefix
% - suffix
% - entities
% - ext
% - prefix
% - suffix
% - entities
% - ext
% - name_spec: structure that must resemble the output of bids.internal.parse_filename
%
%
% - cfg : describes the common properties to be used for several names in the output.
% See ``check_cfg``
%
%
% - list of SPM prefixes from ``get_spm_prefix_list()``
%
% - stc = ''
Expand All @@ -27,8 +27,8 @@
% - smooth = ''
%
% (C) Copyright 2021 spm_2_bids developers
%TODO add a print_mapping method to allow easy visualization

% TODO add a print_mapping method to allow easy visualization
% of the input --> output relationship

properties
Expand Down Expand Up @@ -61,7 +61,7 @@
%
% map = Mapping(cfg)
%
%
%

if nargin == 1
obj.cfg = cfg;
Expand Down Expand Up @@ -91,15 +91,15 @@
% map = add_mapping('prefix', prefix, 'suffix', 'entities', 'ext', 'name_spec')
%

%TODO add possibility to pass "filter" arugment that is a structure
% TODO add possibility to pass "filter" arugment that is a structure
% with shape (allows to chain the output from bids parsing)
%
% filter.prefix
% filter.suffix
% filter.entities
% filter.ext
%
%

p = inputParser;

addParameter(p, 'prefix', obj.default_value);
Expand Down Expand Up @@ -163,7 +163,7 @@
%
% map = map.default;
%

prfx_spec = { ...
{ obj.bias_cor }, obj.cfg.segment.bias_corrected; ...
{ 'c1' }, obj.cfg.segment.gm; ...
Expand Down Expand Up @@ -217,18 +217,18 @@
addParameter(p, 'prefix', @ischar);

parse(p, varargin{:});

available_mapped_prefixes = {obj.mapping.prefix}';

idx = strcmp(p.Results.prefix, available_mapped_prefixes);

end

function obj = rm_mapping(obj, idx)

obj.mapping(idx) = [];
obj.mapping(idx) = [];

end
end

end
end
4 changes: 2 additions & 2 deletions src/defaults/check_cfg.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@
'mode', 'image'), ...
'suffix', 'xfm');

segment.param = struct('label', 'TBD', 'suffix', 'segparam');
segment.param = struct('label', 'TBD', 'suffix', 'segparam');

fields_to_set.segment = segment;

% Preprocessed data
Expand Down
14 changes: 7 additions & 7 deletions src/spm_2_bids.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
% :param file: SPM preprocessed filename (can be fullpath);
% for example ``wmsub-01_ses-01_T1w.nii``
% :type file: string
% :param map: optional spm_2_bids map to overwrite the default
% :param map: optional spm_2_bids map to overwrite the default
% map (see Mapping)
% :param map: Mapping object
%
Expand All @@ -33,9 +33,9 @@

mapping = map.mapping;
cfg = map.cfg;

use_suffix_as_label = false;

% deal with suffixes modified by SPM
% turns them into prefixes that can be handled by the default mapping
if strfind(file, '_uw.mat') %#ok<*STRIFCND>
Expand Down Expand Up @@ -64,13 +64,13 @@

% TODO se if some of the bids-query machinery cannot be kept for identifying
% the right mapping

% look for the right prefix in the mapping
prefix_match = map.find_mapping('prefix', p.prefix);

% TODO implement methods in Mapping to filter by suffix / extention /
% entities

% if any suffix / extention mentioned in the mapping we check for that as well
% if none is mentioned anywhere in the mapping then anything goes
suffix_match = true(size(mapping));
Expand Down Expand Up @@ -118,7 +118,7 @@
end

if isempty(spec)
%TODO this warning should probably go in the find_mapping methods
% TODO this warning should probably go in the find_mapping methods
msg = sprintf('Unknown prefix: %s', p.prefix);
warning('spm_2_bids:unknownPrefix', msg); %#ok<SPWRN>
return
Expand All @@ -127,7 +127,7 @@
spec = add_fwhm_to_smooth_label(spec, cfg);

spec = adapt_from_label_to_input(spec, p);

if use_suffix_as_label
spec.entities.label = p.suffix;
end
Expand Down
8 changes: 4 additions & 4 deletions tests/test_spm_2_bids.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
function test_spm_2_bids_suffix()

input_output = {
'sub-01_T1w_seg8.mat', 'sub-01_label-T1w_segparam.mat';
'sub-01_task-auditory_bold_uw.mat', 'sub-01_task-auditory_label-bold_unwarpparam.mat'};
'sub-01_T1w_seg8.mat', 'sub-01_label-T1w_segparam.mat'
'sub-01_task-auditory_bold_uw.mat', 'sub-01_task-auditory_label-bold_unwarpparam.mat'};

for i = 1:numel(size(input_output, 1))

print_here('%s\n', input_output{i,1});
print_here('%s\n', input_output{i, 1});

filename = spm_2_bids(input_output{i,1});
filename = spm_2_bids(input_output{i, 1});

expected = input_output{i, 2};
assertEqual(filename, expected);
Expand Down

0 comments on commit 39e65b6

Please sign in to comment.