File I/O
- leapctype.tomographicModels.load_parameters(self, parameters_fileName, param_type=0)
Load the CT volume and CT geometry parameters from file
- Parameters:
parameters_fileName (string) – file name of the parameters file to load
param_type (int) – if 0, assumes that parameters_fileName is a file; if 1, assumes that parameters_fileName is the actual content of a parameters file
- leapctype.tomographicModels.load_projections(self, fileName, x=None, fileRange=None, rowRange=None, colRange=None, axis_split=0)
Load 3D projection data from the given file name provided (tif sequence, nrrd, or npy)
See load_data for more information
- leapctype.tomographicModels.load_volume(self, fileName, x=None, fileRange=None, rowRange=None, colRange=None)
Load 3D volume data from the given file name provided (tif sequence, nrrd, or npy)
See load_data for more information
- leapctype.tomographicModels.load_data(self, fileName, x=None, fileRange=None, rowRange=None, colRange=None, axis_split=0)
Load 3D data from file (tif sequence, nrrd, or npy)
This function reads 3D data and stores it in a 3D numpy array. We officially support nrrd, npy, or a a sequence of tif/tiff files. Note that fileRange, rowRange, and colRange arguments only apply to tif sequences.
A tif sequences must be in the following form: basename_XXXX.tif or (tiff). The XXXX are the sequence numbers which can be padded with zeros or not. When calling this function be sure to specify the input as basename.tif, i.e., do not include the underscore and digits when providing this file name to this function.
- Parameters:
fileName (string) – full path to npy or nrrd file or sequence of tif files.
x (3D float32 numpy array) – place to store the data (this argument is optional)
fileRange (list with two integers) – the first and last files to read of a tif sequence
rowRange (list with two integers) – the first and last rows to read in a tif sequence
colRange (list with two integers) – the first and last columns to read in a tif sequence
- Returns:
3D numpy array of the data in the file(s); if x is given, just returns x
- leapctype.tomographicModels.save_parameters(self, fileName)
Save the CT volume and CT geometry parameters to the provided file name
- leapctype.tomographicModels.save_projections(self, fileName, g, sequence_offset=0, axis_split=0)
Save projection data to file (tif sequence, nrrd, or npy)
- Parameters:
fileName (string) – the file name to save the projection data to
g (C contiguous float32 numpy array or torch tensor) – projection data
sequence_offset (int) – if saving as a tif/tiff sequence, this specifies the index of the first file
- leapctype.tomographicModels.save_volume(self, fileName, f, sequence_offset=0)
Save volume data to file (tif sequence, nrrd, or npy)
- Parameters:
fileName (string) – the file name to save the projection data to
f (C contiguous float32 numpy array or torch tensor) – volume data
sequence_offset (int) – if saving as a tif/tiff sequence, this specifies the index of the first file
- leapctype.tomographicModels.set_fileIO_parameters(self, dtype=<class 'numpy.float32'>, wmin=0.0, wmax=None)
This function sets parameters dealing with how tiff stacks are saved
If dtype is np.float32, the data is not clipped
- Parameters:
dtype – the data type to use, can be: np.float32, np.uint8, or np.uint16
wmin (float) – the low value for clipping the data (default is 0.0)
wmax (float) – the high value for clipping the data (default is the max of the 3D data)
- Returns:
True if the dtype is valid, False otherwise