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])Return the time-domain impulse response function.
Get the number of time samples in the dataset.
Return the energy correction factors for the dataset.
Get the list of different reconstruction types.
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 the run number for each of the frames.
Get the scan's sampling frequency.
get_scan_datetime
()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 the scan name.
get_scan_reconstructions
()get_scan_so2
()- param do_detrend:
get_scan_so2_frequency_peak
([fnum])- param fnum:
get_scan_so2_frequency_sum
([fnum])- param fnum:
get_scan_unmixed
()Get the speed of sound of the data if it has been set.
Get the scan timestamps in seconds.
get_ultrasound
()Get the wavelengths used in the scan.
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.
Change the speed of sound for the dataset.
summary_measurements
([metrics, ...])- param metrics:
Attributes
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) –
- 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_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_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_so2_frequency_components(do_detrend=True, fmin=1e-05, fmax=1000, fnum=1000)[source]#
- Parameters:
do_detrend –
fmin –
fmax –
fnum –
- 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