Skip to content

Commit 4c546d0

Browse files
authored
Merge pull request #41 from scientificcomputing/cecile/timestamps
New command - Timestamps
2 parents c59c2db + 784382c commit 4c546d0

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/mritk/looklocker.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def read_dicom_trigger_times(dicomfile: Path) -> np.ndarray:
4141
all_frame_times = [
4242
f.CardiacSynchronizationSequence[0].NominalCardiacTriggerDelayTime for f in dcm.PerFrameFunctionalGroupsSequence
4343
]
44+
4445
return np.unique(all_frame_times)
4546

4647

@@ -310,6 +311,12 @@ def add_arguments(
310311
dicom_parser.add_argument("-i", "--input", type=Path, help="Path to the input Look-Locker DICOM file")
311312
dicom_parser.add_argument("-o", "--output", type=Path, help="Desired output path for the converted .nii.gz file")
312313

314+
ll_timestamps = subparser.add_parser(
315+
"timestamps", help="Read timestamps from DICOM data", formatter_class=parser.formatter_class
316+
)
317+
ll_timestamps.add_argument("-i", "--input", type=Path, help="Path to the input Look-Locker DICOM file")
318+
ll_timestamps.add_argument("-o", "--output", type=Path, help="Desired output path for the generated file")
319+
313320
ll_t1 = subparser.add_parser("t1", help="Generate a T1 map from Look-Locker data", formatter_class=parser.formatter_class)
314321
ll_t1.add_argument("-i", "--input", type=Path, help="Path to the 4D Look-Locker NIfTI file")
315322
ll_t1.add_argument("-t", "--timestamps", type=Path, help="Path to the text file containing trigger delay times (in ms)")
@@ -336,12 +343,17 @@ def add_arguments(
336343
extra_args_cb(dicom_parser)
337344
extra_args_cb(ll_t1)
338345
extra_args_cb(ll_post)
346+
extra_args_cb(ll_timestamps)
339347

340348

341349
def dispatch(args):
342350
command = args.pop("looklocker-command")
343351
if command == "dcm2ll":
344352
dicom_to_looklocker(args.pop("input"), args.pop("output"))
353+
elif command == "timestamps":
354+
timestamps = read_dicom_trigger_times(args.pop("input"))
355+
if args.pop("output") is not None:
356+
np.savetxt(args.pop("output"), timestamps)
345357
elif command == "t1":
346358
looklocker_t1map(args.pop("input"), args.pop("timestamps"), output=args.pop("output"))
347359
elif command == "postprocess":

0 commit comments

Comments
 (0)