Project Modules¶
IO¶
- sand_atlas.io.convert(input_filename, output_filename)¶
Converts data from an input file and saves it to an output file.
- Parameters:
input_filename (str) – The path to the input file containing the data to be converted.
output_filename (str) – The path to the output file where the converted data will be saved.
- Returns:
None
- sand_atlas.io.load_data(filename)¶
Load data from a file based on its extension. Parameters: filename (str): The path to the file to be loaded. Returns: data: The data loaded from the file. The type of data returned depends on the file extension:
For ‘.tif’ or ‘.tiff’ files, returns a memmap or an array from tifffile.
For ‘.raw’ files, returns a memmap from numpy.
For ‘.npz’ files, returns an array from numpy.
For ‘.nrrd’ files, returns the data and header from nrrd.
- sand_atlas.io.save_data(data, filename)¶
Save data to a file with the specified filename and extension.
Parameters: data (array-like): The data to be saved. filename (str): The name of the file to save the data to. The extension of the filename determines the format in which the data will be saved.
Supported file extensions: - ‘tif’ or ‘tiff’: Save data as a TIFF file using tifffile.imsave. - ‘raw’: Save data as a raw binary file using data.tofile. - ‘npz’: Save data as a NumPy compressed file using numpy.savez. - ‘nrrd’: Save data as an NRRD file using nrrd.write.
Raises: ValueError: If the file extension is not supported.