dataset package
dataset.dataset_utils module
- dataset.dataset_utils.calculateAngles(nAngles: int) tensor[source]
Return array of angles in [0, 360) degrees.
- Args:
nAngles (int): Number of desired angles.
- Returns:
angles (tensor): Uniformly spaced angles, excluding 360 degrees.
- dataset.dataset_utils.decimateAngles(nAnglesFull: int, downsample: int) tensor[source]
Decimate an array of angles.
- Args:
nAnglesFull (int): Number of angles at full resolution.
downsample (int): Downsampling factor.
- Returns:
angles (tensor): Array of downsampled angles.
- Example:
As an example, suppose the full set contains 451 angles. Below are various downsampling factors.
4x : 113 views
8x : 57 views
16x : 29 views
32x : 15 views
- dataset.dataset_utils.decimateSinograms(sinograms: tensor, downsample: int)[source]
Decimate the sinograms by angle.
- Args:
sinograms (tensor): Dimensions are
[batchSize, nChannels, nRows (nAngles), nCols].
downsample (int): Downsampling factor
- Returns:
Decimated sinogram tensor.
- dataset.dataset_utils.getMask(imgShape: List[int])[source]
Return a mask of an inscribed circle in the image.
- Args:
imgShape (List[int]): [nRows, nCols]
- Returns:
Mask of 1 inside circle and 0 outside circle
- dataset.dataset_utils.resizeSinograms(sinograms: array, nRows: int = 128)[source]
Reize projection images to (nRows, nRows).
- Args:
sinograms (array): Dimensions are
[nRows, nAngles, nRows (=nColumns)]
nRows (int): Desired image size
- Returns:
Resized sinogram
- dataset.dataset_utils.sampleSinograms(sinograms: tensor, rowRange: List[int])[source]
Calculate train or test set from a subset of rows.
- Args:
sinograms (tensor): Sampled row-by-row.
Dimensions are [batchSize, nAngles, nColumns]. * rowRange (List[int]): Row range to sample. Dimensions are [startRow, endRow].
- Returns:
Sampled sinogram tensor.
dataset.metrics module
- dataset.metrics.calculateMSE(gt: tensor, img: tensor) float[source]
Calculate mean squared error.
- Args:
gt (tensor): Ground truth tensor.
img (tensor): Prediction. Same size as gt.
- Returns:
Mean squared error (float).
dataset.projections module
- dataset.projections.loadSinograms(projDir: str) tensor[source]
Return array of 2D sinograms from row-by-row projections
- Args:
projDir: Directory with .tif files
- Returns:
sinograms (tensor):
(batchSize = nRows) x (nChannels = 1) x nAngles x nColumns
- Notes:
For absorption and dark field, take the neg-log of each projection. For differential or integrated phase, negate each projection to make most values positive.
- dataset.projections.saveMultipleExperiments(projDirs: List[str], trainSinoFile: str, testSinoFile: str)[source]
Load projections, and save them in train and test sets. Uses the top half of each projection for training and the bottom half for testing.
- Args:
projDirs (List[str]): Directories with tif projections.
trainSinoFile (str): Filename to save train projections.
testSinoFile (str): Filename to save test projections.
- Returns:
Saves projections in two files for training and testing.