Skip to content

Commit

Permalink
added probseg to gm mask to avoid empty slices
Browse files Browse the repository at this point in the history
  • Loading branch information
GalKepler committed Dec 19, 2024
1 parent e1153f5 commit eda1c03
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/kepost/workflows/anatomical/procedures/generate_gm.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ def add_gm_from_probseg(in_file: str, probseg: str, threshold: float = 0.0001):
import os

import nibabel as nib
from nilearn.image import resample_to_img

in_image = nib.load(in_file)
in_data = in_image.get_fdata().astype(int)
probseg_image = nib.load(probseg)
probseg_image = resample_to_img(probseg_image, in_image, interpolation="nearest")
in_data = in_image.get_fdata().astype(int)
probseg_data = probseg_image.get_fdata() > threshold
in_data[probseg_data] = 1
out_image = nib.Nifti1Image(in_data, in_image.affine, in_image.header)
Expand Down

0 comments on commit eda1c03

Please sign in to comment.