PAData#

class patato.PAData(scan_reader: ReaderInterface, scan_writer: WriterInterface | None = None)#

Bases: object

A class that contains the interface to access data from a single scan. Any source of scans (e.g. iThera/HDF5/IPASC) can be linked to this.

__init__(scan_reader: ReaderInterface, scan_writer: WriterInterface | None = None) None[source]#
Parameters:
  • scan_reader

  • scan_writer

Methods

__init__(scan_reader[, scan_writer])

param scan_reader:

add_roi(roi_data[, generated])

Add a region of interest to the hdf5 file.

clear_dso2()

close()

copy([cls])

Copy the pa data with changes given.

delete_recons([name, recon_groups])

Delete the reconstructions.

delete_rois([name_position, number])

Delete a roi with name and number.

from_hdf5(filename[, mode])

get_impulse_response()

Return the time-domain impulse response function.

get_n_samples()

Get the number of time samples in the dataset.

get_overall_correction_factor()

Return the energy correction factors for the dataset.

get_recon_types()

Get the list of different reconstruction types.

get_repetition_numbers()

Get the scan repetition numbers for each frame.

get_responding_pixels([nsigma])

param nsigma:

get_rois([filter_rois, interpolate, ...])

Get the regions of interest from the dataset.

get_run_number()

Get the run number for each of the frames.

get_sampling_frequency()

Get the scan's sampling frequency.

get_scan_baseline_icg()

get_scan_baseline_so2()

get_scan_baseline_standard_deviation_icg()

get_scan_baseline_standard_deviation_so2()

get_scan_datetime()

get_scan_dicg()

get_scan_dso2()

get_scan_geometry()

Get the scan detector geometry.

get_scan_images(group[, ignore_default, suffix])

Get the scan images, e.g. reconstructions or so2 etc.

get_scan_mean(dataset[, operation])

param dataset:

get_scan_name()

Get the scan name.

get_scan_reconstructions()

get_scan_so2()

get_scan_so2_frequency_components([...])

param do_detrend:

get_scan_so2_frequency_peak([fnum])

param fnum:

get_scan_so2_frequency_sum([fnum])

param fnum:

get_scan_so2_time_mean()

get_scan_so2_time_standard_deviation()

get_scan_thb()

get_scan_thb_time_mean()

get_scan_unmixed()

get_segmentation()

get_speed_of_sound()

Get the speed of sound of the data if it has been set.

get_time_series()

get_timestamps()

Get the scan timestamps in seconds.

get_ultrasound()

get_wavelengths()

Get the wavelengths used in the scan.

get_z_positions()

Get the z-positions of the sensor.

is_clinical()

rename_roi(old_name, new_name, new_position)

Rename a region of interest.

save_hdf5(filename)

save_to_hdf5(filename)

set_default_recon([rec_name])

Make all returned data be of a particular reconstruction type.

set_speed_of_sound(c)

Change the speed of sound for the dataset.

summary_measurements([metrics, ...])

param metrics:

Attributes

dataset

shape

Returns the shape of the dataset, minus the image size.

add_roi(roi_data: ROI, generated: bool = False) None[source]#

Add a region of interest to the hdf5 file.

Parameters:
  • roi_data (ROI) –

  • generated (bool, default False) –

copy(cls: Type[PAData] | None = None) PAData[source]#

Copy the pa data with changes given.

Parameters:

cls (Type[PAData]) –

Returns:

Copy of the dataset.

Return type:

PAData

property dataset#
delete_recons(name=None, recon_groups: Sequence[str] | None = None)[source]#

Delete the reconstructions.

Parameters:
  • name (str or None) –

  • recon_groups ((iterable of str) or None) –

delete_rois(name_position: str | None = None, number: str | None = None) None[source]#

Delete a roi with name and number. If number is None, will delete all. If name and number is None, delete all.

Parameters:
  • name_position – str or None

  • number – str or none

get_impulse_response() np.ndarray | Array[source]#

Return the time-domain impulse response function.

Returns:

Impulse response function.

Return type:

np.ndarray or pyopencl.array.Array

get_n_samples() int[source]#

Get the number of time samples in the dataset.

Returns:

Number of samples.

Return type:

int

get_overall_correction_factor() np.ndarray | Array | xarray.DataArray[source]#

Return the energy correction factors for the dataset.

Returns:

Overall correction factor.

Return type:

np.ndarray

get_recon_types() list[source]#

Get the list of different reconstruction types.

Returns:

List of different reconstruction types that we have.

Return type:

list

get_repetition_numbers() ndarray[source]#

Get the scan repetition numbers for each frame.

Returns:

Scan repetition numbers.

Return type:

np.ndarray

get_responding_pixels(nsigma=2)[source]#
Parameters:

nsigma

get_rois(filter_rois=None, interpolate: bool = False, get_rim_cores=None, rim_core_distance=None) Dict[Tuple[str, str], ROI][source]#

Get the regions of interest from the dataset.

Parameters:
  • rim_core_distance

  • get_rim_cores

  • filter_rois (dict or None) –

  • interpolate (bool) –

Returns:

dict of {(tuple of (str, str) – Return all the rois.

Return type:

ROI}

get_run_number() ndarray[source]#

Get the run number for each of the frames.

Returns:

Get the run numbers of each of the frames.

Return type:

np.ndarray

get_sampling_frequency() float[source]#

Get the scan’s sampling frequency.

Returns:

Sampling Frequency

Return type:

float

get_scan_baseline_icg()[source]#
get_scan_baseline_so2()[source]#
get_scan_baseline_standard_deviation_icg()[source]#
get_scan_baseline_standard_deviation_so2()[source]#
get_scan_dicg()[source]#
get_scan_dso2()[source]#
get_scan_geometry() np.ndarray | Array[source]#

Get the scan detector geometry.

Return type:

np.ndarray or pyopencl.array.Array

get_scan_images(group: str, ignore_default=False, suffix='') Dict[Tuple[str, str], ImageSequence] | ImageSequence[source]#

Get the scan images, e.g. reconstructions or so2 etc.

Parameters:
  • group (str) – Group to get images from.

  • ignore_default (bool) – Ignore the default reconstruction.

  • suffix (str) – Suffix to add to the image number (e.g. for ICG unmixing).

Returns:

(dict of {tuple of (str, str) – Images of certain type if default recon has been set, or dict or images for all reconstructions.

Return type:

ImageSequence}) or ImageSequence

get_scan_mean(dataset: ImageSequence, operation=<function mean>)[source]#
Parameters:
  • dataset

  • operation

get_scan_name() str[source]#

Get the scan name.

Returns:

Scan name.

Return type:

str

get_scan_so2_frequency_components(do_detrend=True, fmin=1e-05, fmax=1000, fnum=1000)[source]#
Parameters:
  • do_detrend

  • fmin

  • fmax

  • fnum

get_scan_so2_frequency_peak(fnum=1000)[source]#
Parameters:

fnum

get_scan_so2_frequency_sum(fnum=1000)[source]#
Parameters:

fnum

get_scan_so2_time_mean()[source]#
get_scan_so2_time_standard_deviation()[source]#
get_scan_thb()[source]#
get_scan_thb_time_mean()[source]#
get_segmentation()[source]#
get_speed_of_sound() float | None[source]#

Get the speed of sound of the data if it has been set.

Returns:

Speed of sound

Return type:

float or None

get_time_series() PATimeSeries[source]#
get_timestamps() ndarray[source]#

Get the scan timestamps in seconds.

Returns:

Timestamps in seconds.

Return type:

np.ndarray

get_wavelengths() ndarray[source]#

Get the wavelengths used in the scan.

Returns:

Scan Wavelengths.

Return type:

np.ndarray

get_z_positions() ndarray[source]#

Get the z-positions of the sensor.

Returns:

Z-positions array.

Return type:

np.ndarray

rename_roi(old_name: str | Tuple, new_name: str, new_position: str) None[source]#

Rename a region of interest.

Parameters:
  • old_name (str or tuple) – Old roi name e.g. “tumour_left/0” or (“tumour_left”, “0”)

  • new_name (str) – New roi name e.g. “brain”

  • new_position (str) – New roi position e.g. “left”

set_default_recon(rec_name: str | None = None) None[source]#

Make all returned data be of a particular reconstruction type. It is recommended to run this at the start of analysis scripts.

Parameters:

rec_name (tuple of str, optional) –

set_speed_of_sound(c: float) None[source]#

Change the speed of sound for the dataset.

Parameters:

c (float) – Speed of sound.

property shape: Tuple[int]#

Returns the shape of the dataset, minus the image size.

Returns:

Shape of the dataset.

Return type:

tuple of int

summary_measurements(metrics=None, include_rois=None, roi_kwargs=None, just_summary=True, return_masks=False)[source]#
Parameters:
  • metrics

  • include_rois

  • roi_kwargs

  • just_summary