IOFunctions module
This class contains functions pertaining to IO of files based for the RASP code. jsb92, 2024/01/02
- class IOFunctions.IO_Functions
Bases:
object- load_json(filename)
Loads data from a JSON file.
- Parameters:
filename (str) – The name of the JSON file to load.
- Returns:
data (dict) – The loaded JSON data.
- make_directory(directory_path)
Creates a directory if it doesn’t exist.
- Parameters:
directory_path (str) – The path of the directory to be created.
- read_multichannel_tiff_tophotons(file_path, order='tzc', n_t=1, n_z=1, n_c=1)
Read a multichannel TIFF file using the skimage library, averaging/splitting as appropriate. Converts to photons.
Args: - file_path (str): The path to the TIFF file to be read. - order (str): default ‘tzc’, order images are saved in (this defines the averaging).
- Options are:
‘tzc’ (first does all time steps, then does these at different zs, then returns and does other colour channels) ‘tcz’ (first does all time steps, then does different colour channels, then moves in z) ‘ztc’ (first does all z stacks, then repeats at different time steps, then does other colour channels) ‘zct’ (first does all z stacks, then does at different colour channels, then does time steps) ‘ctz’ (first does different colours, then repeats at different time steps, then moves in z) ‘czt’ (first does different colours, then does different z stacks, then does all time steps)
n_t (int): number of time steps per condition. Default 1
n_z (int): number of z stacks per condition. Default 1
n_c (int): number of colours per condition. Default 1
Returns: - image_colourchannels (dict of numpy.ndarrays): Dict of the image data from the TIFF file. Dict will contain N objects that are N colour channels. Final dimension of the NDarrays is the z coordiante.
- read_tiff(file_path)
Read a TIFF file using the skimage library.
- Parameters:
file_path (str) – The path to the TIFF file to be read.
- Returns:
image (numpy.ndarray) – The image data from the TIFF file.
- read_tiff_tophotons(file_path, QE=0.95, gain_map=1.0, offset_map=0.0)
Read a TIFF file using the skimage library. Use camera parameters to convert output to photons
- Parameters:
file_path (str) – The path to the TIFF file to be read.
QR (float) – QE of camera
gain_map (matrix, or float) – gain map. Assumes units of ADU/photoelectrons
offset_map (matrix, or float) – offset map. Assumes units of ADU
- Returns:
image (numpy.ndarray) – The image data from the TIFF file.
- save_analysis_params(analysis_p_directory, to_save, gain_map=0, offset_map=0)
saves analysis parameters.
- Parameters:
analysis_p_directory (str) – The folder to save to.
to_save (dict) – dict to save of analysis parameters.
gain_map (array) – gain_map to save
offset_map (array) – offset_map to save
- save_as_json(data, file_name)
Saves data to a JSON file.
- Parameters:
data (dict) – The data to be saved in JSON format.
file_name (str) – The name of the JSON file.
- write_tiff(volume, file_path, bit=<class 'numpy.uint16'>)
Write a TIFF file using the skimage library.
- Parameters:
volume (numpy.ndarray) – The volume data to be saved as a TIFF file.
file_path (str) – The path where the TIFF file will be saved.
bit (int) – Bit-depth for the saved TIFF file (default is 16).
Notes
The function uses skimage’s imsave to save the volume as a TIFF file. The plugin is set to ‘tifffile’ and photometric to ‘minisblack’. Additional metadata specifying the software as ‘Python’ is included.