nabu.resources.dataset_analyzer
source module nabu.resources.dataset_analyzer
Classes
-
DatasetAnalyzer — Initialize a Dataset analyzer.
-
EDFDatasetAnalyzer — EDF Dataset analyzer for legacy ESRF acquisitions
-
HDF5DatasetAnalyzer — HDF5 dataset analyzer
Functions
-
get_angle_at_index — Return the rotation angle corresponding to image index 'index'
-
get_radio_pair — Get closest radios at radio_angles[0] and radio_angles[1] angles must be in angles
source enum ImageKey(*args, **kwds)
Bases : Enum
Attributes
-
ALIGNMENT
-
PROJECTION
-
FLAT_FIELD
-
DARK_FIELD
-
INVALID
source class DatasetAnalyzer(location, extra_options=None, logger=None)
Initialize a Dataset analyzer.
Parameters
-
location : str — Dataset location (directory or file name)
-
extra_options : dict, optional — Extra options on how to interpret the dataset.
-
logger : logging object, optional — Logger. If not set, messages will just be printed in stdout.
Attributes
-
kind — Base class for datasets analyzers.
-
energy — Return the energy in kev.
-
distance — Return the sample-detector distance in meters.
-
pixel_size — Return the pixel size in microns.
-
rotation_angles — Return the rotation angles in radians.
-
is_halftomo — Indicates whether the current dataset was performed with half acquisition.
-
detector_tilt — Return the detector tilt in degrees
-
projections_srcurrent — Return the synchrotron electric current for each projection.
-
flats_srcurrent — Return the synchrotron electric current for each flat image.
-
flats — Return the REDUCED flat-field images. Either by reducing (median) the raw flats, or a user-defined reduced flats.
-
darks — Return the REDUCED flat-field images. Either by reducing (mean) the raw darks, or a user-defined reduced darks.
-
is_360 — Return True iff the scan is 360 degrees (regardless of half-tomo mode)
Methods
-
check_defined_attribute — Utility function to check that a given attribute is defined.
source property DatasetAnalyzer.energy
Return the energy in kev.
source property DatasetAnalyzer.distance
Return the sample-detector distance in meters.
source property DatasetAnalyzer.pixel_size
Return the pixel size in microns.
source property DatasetAnalyzer.rotation_angles
Return the rotation angles in radians.
source property DatasetAnalyzer.is_halftomo
Indicates whether the current dataset was performed with half acquisition.
source property DatasetAnalyzer.detector_tilt
Return the detector tilt in degrees
source property DatasetAnalyzer.projections
source property DatasetAnalyzer.projections_srcurrent
Return the synchrotron electric current for each projection.
source property DatasetAnalyzer.flats_srcurrent
Return the synchrotron electric current for each flat image.
source method DatasetAnalyzer.check_defined_attribute(name, error_msg=None)
Utility function to check that a given attribute is defined.
Raises
-
ValueError
source property DatasetAnalyzer.flats
Return the REDUCED flat-field images. Either by reducing (median) the raw flats, or a user-defined reduced flats.
source property DatasetAnalyzer.darks
Return the REDUCED flat-field images. Either by reducing (mean) the raw darks, or a user-defined reduced darks.
source property DatasetAnalyzer.scan_basename
source property DatasetAnalyzer.scan_dirname
source method DatasetAnalyzer.get_alignment_projections(image_sub_region=None)
Raises
-
NotImplementedError
source property DatasetAnalyzer.all_angles
source method DatasetAnalyzer.get_frame(idx)
source property DatasetAnalyzer.is_360
Return True iff the scan is 360 degrees (regardless of half-tomo mode)
source class EDFDatasetAnalyzer(location, extra_options=None, logger=None)
Bases : DatasetAnalyzer
EDF Dataset analyzer for legacy ESRF acquisitions
Initialize a Dataset analyzer.
Parameters
-
location : str — Dataset location (directory or file name)
-
extra_options : dict, optional — Extra options on how to interpret the dataset.
-
logger : logging object, optional — Logger. If not set, messages will just be printed in stdout.
Attributes
-
energy — Return the energy in kev.
-
distance — Return the sample-detector distance in meters.
-
pixel_size — Return the pixel size in microns.
-
rotation_angles — Return the rotation angles in radians.
-
is_halftomo — Indicates whether the current dataset was performed with half acquisition.
-
detector_tilt — Return the detector tilt in degrees
-
projections_srcurrent — Return the synchrotron electric current for each projection.
-
flats_srcurrent — Return the synchrotron electric current for each flat image.
-
flats — Return the REDUCED flat-field images. Either by reducing (median) the raw flats, or a user-defined reduced flats.
-
darks — Return the REDUCED flat-field images. Either by reducing (mean) the raw darks, or a user-defined reduced darks.
-
is_360 — Return True iff the scan is 360 degrees (regardless of half-tomo mode)
-
hdf5_entry — Return the HDF5 entry of the current dataset. Not applicable for EDF (return None)
Methods
source property EDFDatasetAnalyzer.hdf5_entry
Return the HDF5 entry of the current dataset. Not applicable for EDF (return None)
source method EDFDatasetAnalyzer.get_reduced_flats(**reader_kwargs)
Raises
-
FileNotFoundError
source method EDFDatasetAnalyzer.get_reduced_darks(**reader_kwargs)
Raises
-
FileNotFoundError
source property EDFDatasetAnalyzer.files
source method EDFDatasetAnalyzer.get_reader(**kwargs)
source property EDFDatasetAnalyzer.scan_basename
source property EDFDatasetAnalyzer.scan_dirname
source method EDFDatasetAnalyzer.get_excluded_projections_indices(including_other_frames_types=True)
Raises
-
NotImplementedError
source class HDF5DatasetAnalyzer(location, extra_options=None, logger=None)
Bases : DatasetAnalyzer
HDF5 dataset analyzer
Initialize a Dataset analyzer.
Parameters
-
location : str — Dataset location (directory or file name)
-
extra_options : dict, optional — Extra options on how to interpret the dataset.
-
logger : logging object, optional — Logger. If not set, messages will just be printed in stdout.
Attributes
-
energy — Return the energy in kev.
-
distance — Return the sample-detector distance in meters.
-
pixel_size — Return the pixel size in microns.
-
rotation_angles — Return the rotation angles in radians.
-
is_halftomo — Indicates whether the current dataset was performed with half acquisition.
-
detector_tilt — Return the detector tilt in degrees
-
projections_srcurrent — Return the synchrotron electric current for each projection.
-
flats_srcurrent — Return the synchrotron electric current for each flat image.
-
flats — Return the REDUCED flat-field images. Either by reducing (median) the raw flats, or a user-defined reduced flats.
-
darks — Return the REDUCED flat-field images. Either by reducing (mean) the raw darks, or a user-defined reduced darks.
-
is_360 — Return True iff the scan is 360 degrees (regardless of half-tomo mode)
-
hdf5_entry — Return the HDF5 entry of the current dataset
Methods
-
get_data_slices — Return indices in the data volume where images correspond to a given kind.
-
frames_slices — Return a list of slice objects corresponding to the data corresponding to "frame_type". For example, if the dataset flats are located at indices [1, 2, ..., 99], then frame_slices("flats") will return [slice(0, 100)].
-
get_alignment_projections — Get the extra projections (if any) that are used as "reference projections" for alignment. For certain scan, when completing a (half) turn, sometimes extra projections are acquired for alignment purpose.
-
get_index_from_angle — Return the index of the image taken at rotation angle 'angle'. By default look at the projections, i.e image_key = 0
-
index_to_proj_number — Return the projection number, from its frame index.
source property HDF5DatasetAnalyzer.z_translation
source property HDF5DatasetAnalyzer.x_translation
source property HDF5DatasetAnalyzer.dataset_hdf5_url
source property HDF5DatasetAnalyzer.hdf5_entry
Return the HDF5 entry of the current dataset
source method HDF5DatasetAnalyzer.get_data_slices(what)
Return indices in the data volume where images correspond to a given kind.
Parameters
-
what : str — Which keys to get. Can be "projections", "flats", "darks"
Returns
-
slices : list of slice — A list where each item is a slice.
source method HDF5DatasetAnalyzer.get_reduced_flats(method='median', force_reload=False, **reader_kwargs)
source method HDF5DatasetAnalyzer.get_reduced_darks(method='mean', force_reload=False, **reader_kwargs)
source method HDF5DatasetAnalyzer.frames_slices(frame_type)
Return a list of slice objects corresponding to the data corresponding to "frame_type". For example, if the dataset flats are located at indices [1, 2, ..., 99], then frame_slices("flats") will return [slice(0, 100)].
source method HDF5DatasetAnalyzer.get_reader(**kwargs)
source property HDF5DatasetAnalyzer.scan_basename
source property HDF5DatasetAnalyzer.scan_dirname
source method HDF5DatasetAnalyzer.get_alignment_projections(image_sub_region=None)
Get the extra projections (if any) that are used as "reference projections" for alignment. For certain scan, when completing a (half) turn, sometimes extra projections are acquired for alignment purpose.
Returns
-
projs : numpy.ndarray — Array with shape (n_projections, n_y, n_x)
-
angles : numpy.ndarray — Corresponding angles in degrees
-
indices — Indices of projections
source property HDF5DatasetAnalyzer.all_angles
source method HDF5DatasetAnalyzer.get_index_from_angle(angle, image_key=0, return_found_angle=False)
Return the index of the image taken at rotation angle 'angle'. By default look at the projections, i.e image_key = 0
source method HDF5DatasetAnalyzer.get_image_at_angle(angle_deg, image_type='projection', sub_region=None, return_angle_and_index=False)
source method HDF5DatasetAnalyzer.get_frame(idx)
source method HDF5DatasetAnalyzer.get_frames_indices(frame_type)
source method HDF5DatasetAnalyzer.index_to_proj_number(proj_index)
Return the projection number, from its frame index.
For example if there are 11 flats before projections, then projections will have indices [11, 12, .....] (possibly not contiguous) while their number is [0, 1, ..., ] (contiguous, starts from 0)
source method HDF5DatasetAnalyzer.get_excluded_projections_indices(including_other_frames_types=True)
source get_angle_at_index(all_angles, index)
Return the rotation angle corresponding to image index 'index'
source get_radio_pair(dataset_info, radio_angles: tuple, return_indices=False)
Get closest radios at radio_angles[0] and radio_angles[1] angles must be in angles
Parameters
-
dataset_info :
[DatasetAnalyzer][__mkapi__.nabu.resources.dataset_analyzer.DatasetAnalyzer]
instance — Data structure with the dataset information -
radio_angles : tuple — tuple of two elements: angles (in radian) to get
-
return_indices : bool, optional — Whether to return radios indices along with the radios array.
Returns
-
res : array or tuple — If return_indices is True, return a tuple (radios, indices). Otherwise, return an array with the radios.
Raises
-
TypeError
source analyze_dataset(dataset_path, extra_options=None, logger=None)
Raises
-
ValueError