2323logger = logging .getLogger (__name__ )
2424
2525
26- def read_dicom_trigger_times (dicomfile : Path ) -> np .ndarray :
26+ def read_dicom_trigger_times (dicomfile : Path , output : Path | None = None ) -> np .ndarray :
2727 """
2828 Extracts unique nominal cardiac trigger delay times from DICOM functional groups.
2929
@@ -41,6 +41,10 @@ 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+
45+ if output is not None :
46+ np .savetxt (output , all_frame_times )
47+
4448 return np .unique (all_frame_times )
4549
4650
@@ -310,6 +314,10 @@ def add_arguments(
310314 dicom_parser .add_argument ("-i" , "--input" , type = Path , help = "Path to the input Look-Locker DICOM file" )
311315 dicom_parser .add_argument ("-o" , "--output" , type = Path , help = "Desired output path for the converted .nii.gz file" )
312316
317+ ll_timestamps = subparser .add_parser ("timestamps" , help = "Read timestamps from DICOM data" , formatter_class = parser .formatter_class )
318+ ll_timestamps .add_argument ("-i" , "--input" , type = Path , help = "Path to the input Look-Locker DICOM file" )
319+ ll_timestamps .add_argument ("-o" , "--output" , type = Path , help = "Desired output path for the generated file" )
320+
313321 ll_t1 = subparser .add_parser ("t1" , help = "Generate a T1 map from Look-Locker data" , formatter_class = parser .formatter_class )
314322 ll_t1 .add_argument ("-i" , "--input" , type = Path , help = "Path to the 4D Look-Locker NIfTI file" )
315323 ll_t1 .add_argument ("-t" , "--timestamps" , type = Path , help = "Path to the text file containing trigger delay times (in ms)" )
@@ -336,12 +344,15 @@ def add_arguments(
336344 extra_args_cb (dicom_parser )
337345 extra_args_cb (ll_t1 )
338346 extra_args_cb (ll_post )
347+ extra_args_cb (ll_timestamps )
339348
340349
341350def dispatch (args ):
342351 command = args .pop ("looklocker-command" )
343352 if command == "dcm2ll" :
344353 dicom_to_looklocker (args .pop ("input" ), args .pop ("output" ))
354+ elif command == "timestamps" :
355+ read_dicom_trigger_times (args .pop ("input" ), args .pop ("output" ))
345356 elif command == "t1" :
346357 looklocker_t1map (args .pop ("input" ), args .pop ("timestamps" ), output = args .pop ("output" ))
347358 elif command == "postprocess" :
0 commit comments