Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package/src/pyaslreport/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ def get_bids_metadata(data):
if sequence is None:
raise ValueError(f"No matching sequence found for modality '{modality}' with the provided DICOM header")

return sequence.extract_bids_metadata()
metadata = sequence.extract_bids_metadata()
asl_context = sequence.generate_asl_context(data.get("nifti_file"))

return metadata, asl_context


def get_dicom_header(dicom_dir: str):
Expand Down
5 changes: 5 additions & 0 deletions package/src/pyaslreport/sequences/base_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def extract_bids_metadata(self) -> dict:
"""Extract and convert DICOM metadata to BIDS fields."""
pass

@abstractmethod
def generate_asl_context(self, nifti_path: str = None) -> list:
"""Generate the ASL context array."""
pass

def _extract_common_metadata(self) -> dict:
"""Extract and convert common DICOM metadata fields to BIDS fields, including ms->s conversion where needed."""
dataset = self.dicom_header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def extract_bids_metadata(self):
bids["PostLabelingDelay"] = dicom_header.get(dcm_tags.GE_INVERSION_TIME, None).value


asl_context = self._generate_asl_context(1)
return bids

return bids, asl_context
def generate_asl_context(self, nifti_path: str = None) -> list:
return self._generate_asl_context(1)

8 changes: 5 additions & 3 deletions package/src/pyaslreport/sequences/ge/asl/ge_easl_multi_pld.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def extract_bids_metadata(self):
bids["LabelingDuration"] = LD_lin
bids["PostLabelingDelay"] = PLD_lin

# ASLcontext: all deltaM, last one is m0scan
asl_context = self._generate_asl_context(npld if npld else 2)
return bids

return bids, asl_context
def generate_asl_context(self, nifti_path: str = None) -> list:
dataset = self.dicom_header
npld = dataset.get(dcm_tags.GE_PRIVATE_CV6, None).value if dcm_tags.GE_PRIVATE_CV6 in dataset else None
return self._generate_asl_context(npld if npld else 2)
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ def extract_bids_metadata(self):
bids["LabelingDuration"] = d.get(dcm_tags.GE_LABEL_DURATION, None).value
if dcm_tags.GE_INVERSION_TIME in d:
bids["PostLabelingDelay"] = d.get(dcm_tags.GE_INVERSION_TIME, None).value
return bids
return bids

def generate_asl_context(self, nifti_path: str = None) -> list:
return ["m0scan", "control", "label"]