Skip to content

Commit 6c1f6f0

Browse files
authored
Fix nifti file conversion (#180)
* use comparisons with absolute path only * change used datatype for segmentation layer when converting from nifti files to uint8, so that max value will not cause overflow in voxelytics pipeline. * Reformat
1 parent 24f3aca commit 6c1f6f0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

wkcuber/convert_nifti.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ def create_parser():
3939
)
4040

4141
parser.add_argument(
42-
"--dtype",
43-
"-d",
44-
help="Target datatype (e.g. uint8, uint16, uint32).",
45-
default="uint8",
42+
"--dtype", "-d", help="Target datatype (e.g. uint8, uint16).", default="uint8"
4643
)
4744

4845
parser.add_argument(
@@ -149,11 +146,13 @@ def convert_folder_nifti(
149146
)
150147
)
151148

149+
logging.info("Segmentation file will also use uint8 as a datatype.")
150+
152151
for path in paths:
153-
if path == color_path.name:
152+
if path == color_path:
154153
convert_nifti(path, target_path, "color", "uint8", scale)
155-
elif path == segmentation_path.name:
156-
convert_nifti(path, target_path, "segmentation", "uint32", scale)
154+
elif path == segmentation_path:
155+
convert_nifti(path, target_path, "segmentation", "uint8", scale)
157156
else:
158157
convert_nifti(path, target_path, path.stem, "uint8", scale)
159158

0 commit comments

Comments
 (0)