Skip to content

Commit b7c6292

Browse files
committed
New command mritk looklocker timestamps, writing tigger times array to file (needed when computing looklocker T1 map)
1 parent c59c2db commit b7c6292

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/mritk/looklocker.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
logger = 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

341350
def 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

Comments
 (0)