-
Notifications
You must be signed in to change notification settings - Fork 24
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 #40 from andypotatohy/gavin
upgrade the sliceshow function by Gavin
- Loading branch information
Showing
5 changed files
with
229 additions
and
70 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
% Crops the image to the brain using segmentation | ||
% Returns the upper and lower bounds of the brain in each direction | ||
% column 1 = R/L, column 2 = A/P, column 3 = S/I | ||
% (c) 2024 Gavin Hsu and Andrew Birnbaum | ||
|
||
function bbox = brainCrop(subj) | ||
[dirname,baseFilename] = fileparts(subj); | ||
seg = [dirname filesep baseFilename,'_masks.nii']; | ||
data = load_untouch_nii(seg); | ||
wm = data.img == 1; | ||
thresh = [0,0,100]; | ||
[bbox(1,1),bbox(2,1)]=bounds(find(sum(sum(wm,2),3)>thresh(1))); | ||
[bbox(1,2),bbox(2,2)]=bounds(find(sum(sum(wm,1),3)>thresh(2))); | ||
[bbox(1,3),bbox(2,3)]=bounds(find(sum(sum(wm,1),2)>thresh(3))); | ||
end |
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
Oops, something went wrong.