alpine.dataloaders package#

Submodules#

alpine.dataloaders.bio module#

alpine.dataloaders.bio.load_nii_gz(filename, data_key='f_data', squeeze_dims=True, normalize=False, normalize_method='minmax', return_as_torch=False)#

_summary_

Parameters:
  • filename (_type_) – _description_

  • data_key (str, optional) – _description_. Defaults to ‘f_data’.

  • squeeze_dims (bool, optional) – _description_. Defaults to True.

  • normalize (bool, optional) – _description_. Defaults to False.

  • normalize_method (str, optional) – _description_. Defaults to ‘minmax’.

  • return_as_torch (bool, optional) – _description_. Defaults to False.

Returns:

_description_

Return type:

_type_

alpine.dataloaders.bio.load_pdb(filename, model_index=1)#

Loading PDF file using PandasPdb

Code adapted from Biopandas and @jgbrasier https://medium.com/@jgbrasier/working-with-pdb-files-in-python-7b538ee1b5e4

Parameters:
  • filename (_type_) – _description_

  • model_index (int, optional) – _description_. Defaults to 1.

Returns:

_description_

Return type:

_type_

alpine.dataloaders.bio.normalize_fn(x, normalize_method='minmax')#

alpine.dataloaders.coordinate_datasets module#

class alpine.dataloaders.coordinate_datasets.BatchedCoordinateDataset#

Bases: Dataset

__getitem__(idx)#

Returns a batch of coordinates based on the specified index.

Parameters:

idx (int) – Index of the batch to be returned.

Returns:

Batch of coordinates.

Return type:

torch.Tensor

__init__(grid_dims: tuple, bounds: tuple = (-1, 1), vectorized=True)#

PyTorch dataloader for generating coordinate datasets in batches.

Parameters:
  • grid_dims (tuple) – Input d-dimensional grid dimensions.

  • bounds (tuple) – Bounds of the grid. Defaults to (-1, 1).

  • vectorized (bool) – If True, returns a vectorized grid of shape N x d. Defaults to True.

build_coordinate_tensors()#

Builds coordinate tensors based on the specified grid dimensions. Used internally by BatchedCoordinateDataset.

class alpine.dataloaders.coordinate_datasets.CoordinateDataset#

Bases: Dataset

PyTorch Dataset for generating a grid of coordinates as input to the network.

__init__(grid_dims: tuple, bounds: tuple = (-1, 1), vectorized=True)#
build_coordinate_tensors()#

Builds coordinate tensors based on the specified grid dimensions. Used internally by BatchedCoordinateDataset.

alpine.dataloaders.coordinate_datasets.unflat_index(index, shape_of_tensor)#

alpine.dataloaders.dataio module#

alpine.dataloaders.env module#

alpine.dataloaders.env.load_nlcd(path, return_onehot=False, use_colormap=False)#
alpine.dataloaders.env.nlcd_to_integer_index(nlcd_arr)#
alpine.dataloaders.env.remap_nlcd(x)#

alpine.dataloaders.signal_dataloaders module#

class alpine.dataloaders.signal_dataloaders.BatchedNDSignalLoader#

Bases: Dataset

__getitem__(idx)#

Returns a batch of signal data based on the specified index.

Parameters:

idx (int) – Index of the batch to be returned.

Returns:

Batch of signal data.

Return type:

torch.Tensor

__init__(signal: ndarray | Tensor, grid_dims: tuple, bounds: tuple = (-1, 1), vectorized: bool = True, normalize_signal: bool = True, normalize_fn: callable | None = None)#

_summary_

Parameters:
  • signal (Any) – Indexible object containing the signal data. Can be numpy array, list, torch.Tensor, etc. Must be of shape grid_dims[0] x grid_dims[1] x … x grid_dims[n] x (optional channels).

  • grid_dims (tuple) – _description_

  • bounds (tuple, optional) – _description_. Defaults to (-1, 1).

  • vectorized (bool, optional) – _description_. Defaults to True.

  • normalize_signal (bool, optional) – Min max normalization of the signal. Defaults to True.

  • normalize_fn (callable, optional) – custom callable function to normalize signal. Function will accept the signal as an argument. Defaults to None.

build_coordinate_tensors()#

Builds coordinate tensors based on the specified grid dimensions. Used internally by BatchedCoordinateDataset.

setup_signal(signal)#

Sets up the signal for the dataset. This includes reshaping, normalizing, and converting to a tensor if necessary. Used internally by BatchedNDSignalLoader.

class alpine.dataloaders.signal_dataloaders.NDSignalLoader#

Bases: Dataset

__getitem__(idx)#

Returns a batch of signal data based on the specified index.

Parameters:

idx (int) – Index of the batch to be returned.

Returns:

Batch of signal data.

Return type:

torch.Tensor

__init__(signal: ndarray | Tensor, grid_dims: tuple, bounds: tuple = (-1, 1), vectorized: bool = True, normalize_signal: bool = True, normalize_fn: callable | None = None)#

_summary_

Parameters:
  • signal (Any) – Indexible object containing the signal data. Can be numpy array, list, torch.Tensor, etc.

  • grid_dims (tuple) – _description_

  • bounds (tuple, optional) – _description_. Defaults to (-1, 1).

  • vectorized (bool, optional) – _description_. Defaults to True.

  • normalize_signal (bool, optional) – Min max normalization of the signal. Defaults to True.

  • normalize_fn (callable, optional) – custom callable function to normalize signal. Function will accept the signal as an argument. Defaults to None.

build_coordinate_tensors()#

Builds coordinate tensors based on the specified grid dimensions. Used internally by BatchedCoordinateDataset.

setup_signal(signal)#

Sets up the signal for the dataset. This includes reshaping, normalizing, and converting to a tensor if necessary. Used internally by NDSignalLoader.

Module contents#