Skip to content

Siemens' TWIX reader does not pass voxel dimension to MRSData object #176

@darrencl

Description

@darrencl

In the TwixBuilder.build_mrsdata(), the voxel dimension does not seem to be included when constructing the object, nor returned in the parse_twix_header() method.

  • TwixBuilder.build_mrsdata()

    mrs_data = MRSData(data,
    self.header_params["dt"],
    self.header_params["f0"],
    te=self.header_params["te"],
    tr=self.header_params["tr"],
    metadata=metadata,
    transform=self.header_params["transform"])

  • parse_twix_header()

    suspect/suspect/io/twix.py

    Lines 284 to 299 in 86d3c37

    return {"protocol_name": protocol_name,
    "patient_name": patient_name,
    "patient_id": patient_id,
    "patient_birthdate": patient_birthday,
    "dt": dwell_time,
    "f0": frequency,
    "transform": transform,
    "te": te,
    "tr": tr,
    "exam_date": exam_date,
    "exam_time": exam_time,
    "sequence_name": sequence_name,
    "software_version": software_version,
    "manufacturer": manufacturer,
    "manufacturers_model_name": manufacturers_model_name
    }

However, I can see that it is extracted here:

suspect/suspect/io/twix.py

Lines 179 to 197 in 86d3c37

# get voxel size
ro_fov_matches = [
r"sSpecPara\.sVoI\.dReadoutFOV\s*=\s*(-?[[0-9]*[.]?[0-9]*]{0,})\s*",
r"<ParamDouble.\"VoI_RoFOV\"> { <Precision> \d+( -?[0-9\.]+)? }",
r"<ParamDouble\.\"VoI_RoFOV\">\s*{\s*(-?[0-9\.]+)?\s*}"
]
pe_fov_matches = [
r"sSpecPara\.sVoI\.dPhaseFOV\s*=\s*(-?[[0-9]*[.]?[0-9]*]{0,})\s*",
r"<ParamDouble.\"VoI_PeFOV\"> { <Precision> \d+( -?[0-9\.]+)? }",
r"<ParamDouble\.\"VoI_PeFOV\">\s*{\s*(-?[0-9\.]+)?\s*}"
]
slice_thickness_matches = [
r"sSpecPara\.sVoI\.dThickness\s*=\s*(-?[[0-9]*[.]?[0-9]*]{0,})\s*",
r"<ParamDouble.\"VoI_SliceThickness\"> { <Precision> \d+( -?[0-9\.]+)? }",
r"<ParamDouble\.\"VoI_SliceThickness\">\s*{\s*(-?[0-9\.]+)?\s*}"
]
ro_fov = get_meta_regex(ro_fov_matches, header_string, default=0)
pe_fov = get_meta_regex(pe_fov_matches, header_string, default=0)
slice_thickness = get_meta_regex(slice_thickness_matches, header_string, default=0)

which is then used in transformation_matrix():

suspect/suspect/io/twix.py

Lines 279 to 282 in 86d3c37

transform = transformation_matrix(row_vector,
column_vector,
[pos_sag, pos_cor, pos_tra],
[ro_fov, pe_fov, slice_thickness])

To confirm, I compared to Siemens' DICOM reader and we can see voxel size/dimension is the last argument of

voxel_size = (*csa_header["PixelSpacing"],
csa_header["SliceThickness"])
transform = transformation_matrix(row_vector,
column_vector,
csa_header["VoiPosition"],
voxel_size)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions