-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from adhusch/develop
Regular Merge
- Loading branch information
Showing
8 changed files
with
76 additions
and
6 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 |
---|---|---|
|
@@ -22,7 +22,15 @@ | |
% (c) 2017 | ||
% [email protected], [email protected] | ||
function transPoints = applyANTSTransformToPoints(points, antsTransformFileStrings) | ||
applyTransformsToPointsCmd = '/Applications/ANTSGit/bin/antsApplyTransformsToPoints'; % FIXME: Make multi-os compatabile and find bins automatically | ||
try | ||
[~, t] = system('echo $ANTSPATH'); | ||
antspath = t(1:end-1); % remove line ending | ||
end | ||
if(~isempty(t)) | ||
applyTransformsToPointsCmd = [antspath 'antsApplyTransformsToPoints']; | ||
else | ||
applyTransformsToPointsCmd = 'antsApplyTransformsToPoints'; % FIXME: Make multi-os compatabile and find bins automatically | ||
end | ||
|
||
tempFile = [tempname() '.csv']; | ||
tempFileOut = [tempname() '.csv']; | ||
|
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
function nii = applyNiiIntensityScaling(nii) | ||
% Code extracte from Jimmy Shen's ([email protected]) xform_nii.m | ||
% method, which is part of the nifti toolbox | ||
% | ||
% Andreas Husch, 2019 | ||
|
||
% if scl_slope field is nonzero, then each voxel value in the | ||
% dataset should be scaled as: y = scl_slope * x + scl_inter | ||
% I bring it here because hdr will be modified by change_hdr. | ||
% | ||
if nii.hdr.dime.scl_slope ~= 0 & ... | ||
ismember(nii.hdr.dime.datatype, [2,4,8,16,64,256,512,768]) & ... | ||
(nii.hdr.dime.scl_slope ~= 1 | nii.hdr.dime.scl_inter ~= 0) | ||
|
||
nii.img = ... | ||
nii.hdr.dime.scl_slope * double(nii.img) + nii.hdr.dime.scl_inter; | ||
|
||
if nii.hdr.dime.datatype == 64 | ||
|
||
nii.hdr.dime.datatype = 64; | ||
nii.hdr.dime.bitpix = 64; | ||
else | ||
nii.img = single(nii.img); | ||
|
||
nii.hdr.dime.datatype = 16; | ||
nii.hdr.dime.bitpix = 32; | ||
end | ||
|
||
nii.hdr.dime.glmax = max(double(nii.img(:))); | ||
nii.hdr.dime.glmin = min(double(nii.img(:))); | ||
|
||
% set scale to non-use, because it is applied in xform_nii | ||
% | ||
nii.hdr.dime.scl_slope = 0; | ||
|
||
end | ||
|
||
% However, the scaling is to be ignored if datatype is DT_RGB24. | ||
|
||
% If datatype is a complex type, then the scaling is to be applied | ||
% to both the real and imaginary parts. | ||
% | ||
if nii.hdr.dime.scl_slope ~= 0 & ... | ||
ismember(nii.hdr.dime.datatype, [32,1792]) | ||
|
||
nii.img = ... | ||
nii.hdr.dime.scl_slope * double(nii.img) + nii.hdr.dime.scl_inter; | ||
|
||
if nii.hdr.dime.datatype == 32 | ||
nii.img = single(nii.img); | ||
end | ||
|
||
nii.hdr.dime.glmax = max(double(nii.img(:))); | ||
nii.hdr.dime.glmin = min(double(nii.img(:))); | ||
|
||
% set scale to non-use, because it is applied in xform_nii | ||
% | ||
nii.hdr.dime.scl_slope = 0; | ||
|
||
end | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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