pytomography.io#

Submodules#

Package Contents#

Functions#

simind_CT_to_data(headerfile)

Opens attenuation data from SIMIND output

simind_projections_to_data(headerfile[, distance])

Obtains ObjectMeta, ImageMeta, and projections from a SIMIND header file.

simind_MEW_to_data(headerfiles[, distance])

Opens multiple projection files corresponding to the primary, lower scatter, and upper scatter windows

get_SPECT_recon_algorithm_simind(projections_header[, ...])

dicom_projections_to_data(file)

Obtains ObjectMeta, ImageMeta, and projections from a .dcm file.

dicom_CT_to_data(files_CT, file_NM[, ...])

Converts a sequence of DICOM CT files (corresponding to a single scan) into a torch.Tensor object usable as an attenuation map in PyTomography. This is primarily intended for opening pre-reconstructed CT data such that it can be used as an attenuation map during PET/SPECT reconstruction.

dicom_MEW_to_data(file[, type])

get_SPECT_recon_algorithm_dicom(projections_file[, ...])

Helper function to quickly create reconstruction algorithm given SPECT DICOM files and CT dicom files.

pytomography.io.simind_CT_to_data(headerfile)[source]#

Opens attenuation data from SIMIND output

Parameters:

headerfile (str) – Path to header file

Returns:

Tensor containing CT data.

Return type:

torch.tensor[Lx,Ly,Lz]

pytomography.io.simind_projections_to_data(headerfile, distance='cm')[source]#

Obtains ObjectMeta, ImageMeta, and projections from a SIMIND header file.

Parameters:
  • headerfile (str) – Path to the header file

  • distance (str, optional) – The units of measurements in the SIMIND file (this is required as input, since SIMIND uses mm/cm but doesn’t specify). Defaults to ‘cm’.

Returns:

Required information for reconstruction in PyTomography.

Return type:

(ObjectMeta, ImageMeta, torch.Tensor[1, Ltheta, Lr, Lz])

pytomography.io.simind_MEW_to_data(headerfiles, distance='cm')[source]#

Opens multiple projection files corresponding to the primary, lower scatter, and upper scatter windows

Parameters:
  • headerfiles (list[str]) – List of file paths to required files. Must be in order of: 1. Primary, 2. Lower Scatter, 3. Upper scatter

  • distance (str, optional) – The units of measurements in the SIMIND file (this is required as input, since SIMIND uses mm/cm but doesn’t specify). Defaults to ‘cm’.

Returns:

Required information for reconstruction in PyTomography. First returned tensor contains primary data, and second returned tensor returns estimated scatter using the triple energy window method.

Return type:

(ObjectMeta, ImageMeta, torch.Tensor[1, Ltheta, Lr, Lz], torch.Tensor[1, Ltheta, Lr, Lz])

pytomography.io.get_SPECT_recon_algorithm_simind(projections_header, scatter_headers=None, CT_header=None, psf_meta=None, prior=None, object_initial=None, recon_algorithm_class=OSEMOSL)[source]#
Parameters:
Return type:

torch.nn.Module

pytomography.io.dicom_projections_to_data(file)[source]#

Obtains ObjectMeta, ImageMeta, and projections from a .dcm file.

Parameters:

file (str) – Path to the .dcm file

Returns:

Required information for reconstruction in PyTomography.

Return type:

(ObjectMeta, ImageMeta, torch.Tensor[1, Ltheta, Lr, Lz])

pytomography.io.dicom_CT_to_data(files_CT, file_NM, photopeak_window_index=0)[source]#

Converts a sequence of DICOM CT files (corresponding to a single scan) into a torch.Tensor object usable as an attenuation map in PyTomography. This is primarily intended for opening pre-reconstructed CT data such that it can be used as an attenuation map during PET/SPECT reconstruction.

Parameters:
  • files_CT (Sequence[str]) – List of all files corresponding to an individual CT scan

  • file_NM (str) – File corresponding to raw PET/SPECT data (required to align CT with projections)

  • photopeak_window_index (int, optional) – Index corresponding to photopeak in projection data. Defaults to 0.

Returns:

Tensor of shape [Lx, Ly, Lz] corresponding to attenuation map.

Return type:

torch.Tensor

pytomography.io.dicom_MEW_to_data(file, type='DEW')[source]#
pytomography.io.get_SPECT_recon_algorithm_dicom(projections_file, atteunation_files=None, use_psf=False, scatter_type=None, prior=None, recon_algorithm_class=OSEMOSL, object_initial=None)[source]#

Helper function to quickly create reconstruction algorithm given SPECT DICOM files and CT dicom files.

Parameters:
  • projections_file (str) – DICOM filepath corresponding to SPECT data.

  • atteunation_files (Sequence[str], optional) – DICOM filepaths corresponding to CT data. If None, then atteunation correction is not used. Defaults to None.

  • use_psf (bool, optional) – Whether or not to use PSF modeling. Defaults to False.

  • scatter_type (str | None, optional) – Type of scatter correction used in reconstruction. Defaults to None.

  • prior (Prior, optional) – Bayesian Prior used in reconstruction algorithm. Defaults to None.

  • recon_algorithm_class (nn.Module, optional) – Type of reconstruction algorithm used. Defaults to OSEMOSL.

  • object_initial (torch.Tensor | None, optional) – Initial object used in reconstruction. If None, defaults to all ones. Defaults to None.

Raises:

Exception – If not able to compute relevant PSF parameters from DICOM data and corresponding data tables.

Returns:

Reconstruction algorithm used.

Return type:

OSML