Skip to content

Commit 22df73a

Browse files
committed
[Feature] <Allow reading of DICOM images> #68
Fixed the --series_number validation
1 parent 5347a31 commit 22df73a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

WrapImage/dicom2niix_wrapper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def prompt_output_directory(input_dir):
4949
return os.path.abspath(os.path.join(input_dir, answer.strip("./")))
5050

5151

52-
def dicom_to_niix(vol_dir: Path, out_dir: Path, merge_2d: bool = False, series_num: int = -1, is_single_file: bool = False):
52+
def dicom_to_niix(vol_dir: Path, out_dir: Path, merge_2d: bool = False, series_num: int = -2, is_single_file: bool = False):
5353
"""
5454
For converting DICOM images to a (compresssed) 4d nifti image
5555
"""
@@ -66,7 +66,7 @@ def dicom_to_niix(vol_dir: Path, out_dir: Path, merge_2d: bool = False, series_n
6666
# https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage
6767
# for further configuration for general usage see page above
6868
]
69-
if series_num >= 0:
69+
if series_num >= -1:
7070
cmd.extend(["-n", str(series_num)])
7171
cmd.append(str(vol_dir)) # input directory
7272

@@ -195,7 +195,7 @@ def run_cli(input_path: str, output_path: str, **kwargs):
195195
out_dir = Path(output_path)
196196

197197
merge_2d = kwargs.get("merge_2d", False)
198-
series_num = kwargs.get("series_number", -1)
198+
series_num = kwargs.get("series_number", -2)
199199
single_file = kwargs.get("single_file", False)
200200

201201
print(f" Converting:\n → Input: {vol_dir}\n → Output: {out_dir}")
@@ -220,7 +220,7 @@ def run_cli(input_path: str, output_path: str, **kwargs):
220220
parser = argparse.ArgumentParser(description="DICOM to NIfTI converter with optional IVIM processing")
221221
parser.add_argument("input", nargs="?", help="Path to input DICOM directory")
222222
parser.add_argument("output", nargs="?", help="Path to output directory for NIfTI files")
223-
parser.add_argument("-n", "--series-number", type=int, default=-1, help="Only convert this series number (-n <num>)")
223+
parser.add_argument("-n", "--series-number", type=int, default=-2, help="Only convert this series number (-n <num>)")
224224
parser.add_argument("-m", "--merge-2d", action="store_true", help="Merge 2D slices (-m y)")
225225
parser.add_argument("-s", "--single-file", action="store_true", help="Enable single file mode (-s y)")
226226
parser.add_argument("-pu", "--prompt-user", action="store_true", help="Run in interactive mode")

0 commit comments

Comments
 (0)