psf_generator.utils.handle_data#
A collection of functions to handle loading and saving of data and image.
image uses common image formats, e.g., .tif
npy uses numpy data format .npy for images
csv uses .csv for statistical data
Notes#
save_image follows convention (spatial dimensions, channels), i.e. it changes the axes of the input image. For tests, we save images in .npy format to avoid this inconvenience.
Functions#
|
Load data from filepath. |
|
Save image in specified format to specified location. |
|
Save data as a numpy array in a .npy file. |
|
Load numpy array from a file. |
|
Save statistical data to a csv file for further analysis or plotting. |
|
Load data from a csv file. |
Module Contents#
- psf_generator.utils.handle_data.load_image(filepath: str)[source]#
Load data from filepath.
Parameters#
- filepathstr
Path to the file.
- psf_generator.utils.handle_data.save_image(filepath: str, image: torch.Tensor | numpy.ndarray)[source]#
Save image in specified format to specified location.
Parameters#
- filepathstr
Path to save the file.
- imagetorch.Tensor or np.ndarray
Image to be saved.
Notes#
Scikit-image and tifffile both follow the convention of putting the channel dimension after x and y. The saved tif image thus has dimension (z, x, y, channels) instead of (z, channels, x, y).
- psf_generator.utils.handle_data.save_as_npy(filepath: str, input_data: torch.Tensor | numpy.ndarray)[source]#
Save data as a numpy array in a .npy file.
Parameters#
- filepathstr
Path to save the file.
- input_datatorch.Tensor or np.ndarray
Data to be saved
- psf_generator.utils.handle_data.load_from_npy(filepath: str) numpy.ndarray[source]#
Load numpy array from a file.
Parameters#
- filepathstr
Path to file.
Returns#
- outputnp.ndarray
Loaded array.
- psf_generator.utils.handle_data.save_stats_as_csv(filepath: str, data: list)[source]#
Save statistical data to a csv file for further analysis or plotting.
Statistical data such as the runtime values is saved as a list of tuples (index, value).
Parameters#
- filepathstr
Path to the file to store the statistics.
- datalist
Statistics to be saved.