Skip to content

Commit c4e06e0

Browse files
committed
add Manual metadata to output of segmentation
1 parent 09da459 commit c4e06e0

File tree

5 files changed

+47
-23
lines changed

5 files changed

+47
-23
lines changed

src/spm_2_bids.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@
148148

149149
json = bids.derivatives_json(bf.filename);
150150

151+
if strcmp(bf.suffix, 'probseg')
152+
json.content.Manual = false;
153+
end
154+
151155
content = json.content;
152156

153157
content.RawSources = identify_rawsources(file, verbose);

src/utils/identify_rawsources.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
derivatives = strrep(derivatives, '_uw.mat', '.nii');
4040
end
4141

42-
bf = bids.File(derivatives, 'verbose', verbose);
42+
bf = bids.File(derivatives, 'verbose', verbose, 'use_schema', false);
4343

4444
bf.prefix = '';
4545

src/utils/identify_sources.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@
113113
bf.prefix = bf.prefix(2:end);
114114
end
115115

116+
elseif ismember(bf.prefix(1:2), {'c1', 'c2', 'c3', 'c4', 'c5'})
117+
% TODO bias corrected image
118+
sources = 'TODO';
119+
return
120+
116121
elseif startsWith(bf.prefix, 'u')
117122
bf.prefix = bf.prefix(2:end);
118123

tests/test_identify_sources.m

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@
88
initTestSuite;
99
end
1010

11+
function test_identify_sources_anat()
12+
13+
anat_file = 'sub-01_T1w.nii';
14+
15+
prefix_output = {'wm', 'sub-01/sub-01_space-individual_desc-biascor_T1w.nii'
16+
'wc1', 'sub-01/sub-01_space-individual_label-GM_probseg.nii'
17+
'wc2', 'sub-01/sub-01_space-individual_label-WM_probseg.nii'
18+
'wc3', 'sub-01/sub-01_space-individual_label-CSF_probseg.nii'
19+
'wc1', 'sub-01/sub-01_space-individual_label-GM_probseg.nii'
20+
};
21+
22+
map = default_mapping();
23+
24+
for i = 1:size(prefix_output, 1)
25+
26+
sources = identify_sources([prefix_output{i, 1} anat_file], map, false);
27+
28+
assertEqual(sources{1}, prefix_output{i, 2});
29+
30+
end
31+
32+
end
33+
1134
function test_identify_sources_func()
1235

1336
func_file = 'sub-01_task-auditory_bold.nii';
@@ -60,28 +83,6 @@ function test_identify_sources_mean()
6083

6184
end
6285

63-
function test_identify_sources_anat()
64-
65-
anat_file = 'sub-01_T1w.nii';
66-
67-
prefix_output = {'wm', 'sub-01/sub-01_space-individual_desc-biascor_T1w.nii'
68-
'wc1', 'sub-01/sub-01_space-individual_label-GM_probseg.nii'
69-
'wc2', 'sub-01/sub-01_space-individual_label-WM_probseg.nii'
70-
'wc3', 'sub-01/sub-01_space-individual_label-CSF_probseg.nii'
71-
};
72-
73-
map = default_mapping();
74-
75-
for i = 1:size(prefix_output, 1)
76-
77-
sources = identify_sources([prefix_output{i, 1} anat_file], map, false);
78-
79-
assertEqual(sources{1}, prefix_output{i, 2});
80-
81-
end
82-
83-
end
84-
8586
function test_identify_sources_suffix()
8687

8788
input_output = {'msub-01_T1w_seg8.mat', ...

tests/test_spm_2_bids_metadata.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
initTestSuite;
99
end
1010

11+
function test_spm_2_bids_metadata_probseg()
12+
13+
file = 'c1sub-01_T1w.nii';
14+
15+
[~, ~, json] = spm_2_bids(file, [], false);
16+
17+
assertEqual(fieldnames(json), {'filename'; 'content'});
18+
assertEqual(json.content.RawSources{1}, 'sub-01/sub-01_T1w.nii');
19+
assertEqual(json.content.Manual, false);
20+
21+
bids.util.jsonencode(json.filename, json.content);
22+
23+
end
24+
1125
function test_spm_2_bids_metadata_smoothed_data()
1226

1327
file = 's6wusub-01_task-auditory_bold.nii';

0 commit comments

Comments
 (0)