Skip to content

Commit 282d8b4

Browse files
committed
add thresholding description to mask filename
1 parent 92b11d4 commit 282d8b4

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/roi/thresholdToMask.m

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,28 @@
3838
peakThreshold = p.Results.peakThreshold;
3939
clusterSize = p.Results.clusterSize;
4040

41+
[l2, num] = getClusters(inputImage, peakThreshold);
42+
vol = sortAndThresholdClusters(l2, num, clusterSize);
43+
4144
% create output name
4245
p = bids.internal.parse_filename(inputImage);
46+
4347
p.suffix = 'mask';
48+
if ~isfield(p.entities, 'desc')
49+
p.entities.desc = '';
50+
end
51+
descSuffix = sprintf('p%05.2f', peakThreshold);
52+
if clusterSize > 0
53+
descSuffix = [descSuffix, sprintf('k%03.0f', clusterSize)];
54+
end
55+
descSuffix = strrep(descSuffix, '.', 'pt');
56+
p.entities.desc = [p.entities.desc descSuffix];
57+
4458
bidsFile = bids.File(p);
4559
hdr = spm_vol(inputImage);
4660
hdr.fname = spm_file(hdr.fname, 'filename', bidsFile.filename);
4761
outputImage = hdr.fname;
4862

49-
[l2, num] = getClusters(inputImage, peakThreshold);
50-
vol = sortAndThresholdClusters(l2, num, clusterSize);
51-
5263
spm_write_vol(hdr, vol);
5364

5465
json = bids.derivatives_json(outputImage);

tests/test_thresholdToMask.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function test_thresholdToMask_default()
1717

1818
inputImage = setUp(image);
1919

20-
peakThreshold = 5;
20+
peakThreshold = 5.0;
2121
outputImage = thresholdToMask(inputImage, peakThreshold);
2222

2323
% check that we have certain number voxels in the mask

0 commit comments

Comments
 (0)