simind_io#

Module Contents#

Functions#

get_header_value(list_of_attributes, header[, dtype, ...])

Finds the first entry in an Interfile with the string header

get_projections_from_single_file(headerfile)

Gets projection data from a SIMIND header file.

get_projections(headerfiles)

Obtains projection PSF data from a list of headerfiles and concatenates them together

get_source_detector_distances(resfiles)

Obtains the source-detector distance from a list of resfiles

get_meshgrid(resfiles[, device])

Obtains a meshgrid of the x and y coordinates correpsonding to the PSF data simulated

Attributes#

simind_io.relation_dict[source]#
simind_io.get_header_value(list_of_attributes, header, dtype=np.float32, split_substr=':=', split_idx=-1, return_all=False)[source]#

Finds the first entry in an Interfile with the string header

Parameters:
  • list_of_attributes (list[str]) – Simind data file, as a list of lines.

  • header (str) – The header looked for

  • dtype (type, optional) – The data type to be returned corresponding to the value of the header. Defaults to np.float32.

Returns:

The value corresponding to the header (header).

Return type:

float|str|int

simind_io.get_projections_from_single_file(headerfile)[source]#

Gets projection data 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:

Simulated SPECT projection data.

Return type:

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

simind_io.get_projections(headerfiles)[source]#

Obtains projection PSF data from a list of headerfiles and concatenates them together

Parameters:

headerfiles (str | Sequence[str]) – List of length Ld corresponding to all projections at different source-detector distances.

Returns:

Output tensor of PSF data at each source-detector distance

Return type:

torch.Tensor[Ld,Lx,Ly]

simind_io.get_source_detector_distances(resfiles)[source]#

Obtains the source-detector distance from a list of resfiles

Parameters:

resfiles (str) – List of .res files (of length Ld) corresponding to each simulated PSF projection

Returns:

List of source-detector distances

Return type:

torch.Tensor[Ld]

simind_io.get_meshgrid(resfiles, device='cpu')[source]#

Obtains a meshgrid of the x and y coordinates correpsonding to the PSF data simulated

Parameters:
  • resfiles (str) – List of .res files (of length Ld) corresponding to each simulated PSF projection

  • device (str, optional) – Device to place the output projection data on. Defaults to ‘cpu’.

Returns:

Meshgrid of x and y coordinates

Return type:

tuple[torch.Tensor, torch.Tensor]