Exemplo n.º 1
0
    def __init__(
        self,
        col_index: Optional[str] = None,
        col_signal: str = "path_signal",
        col_target: str = "path_target",
        col_weight_map: str = "path_weight_map",
        augment: bool = False,
        **kwargs,
    ):
        super().__init__(**kwargs)
        self.col_index = col_index
        self.col_signal = col_signal
        self.col_target = col_target
        self.col_weight_map = col_weight_map
        self.augment = augment
        if self.col_index is not None:
            self.df = self.df.set_index(self.col_index)
        if self.augment:
            self.df = add_augmentations(self.df)
        if self.col_weight_map not in self.df.columns:
            self.col_weight_map = None

        for col in [self.col_signal, self.col_target, self.col_weight_map]:
            if col is not None and col not in self.df.columns:
                raise ValueError(f"{col} not a dataset DataFrame column")
Exemplo n.º 2
0
 def __init__(self, augment: bool = False, **kwargs):
     super().__init__(**kwargs)
     assert all(col in self.df.columns
                for col in ['path_signal', 'path_target'])
     self.augment = augment
     if self.augment:
         self.df = add_augmentations(self.df)
Exemplo n.º 3
0
def DummyCustomFnetDataset(train: bool = False) -> TiffDataset:
    """Returns a dummy custom dataset."""
    df = pd.DataFrame({
        "path_signal": [os.path.join("data", "EM_low.tif")],
        "path_target": [os.path.join("data", "MBP_low.tif")],
    })
    if not train:
        df = add_augmentations(df)
    return _CustomDataset(df)
Exemplo n.º 4
0
def DummyFnetDataset(train: bool = False) -> TiffDataset:
    """Returns a dummy Fnetdataset."""
    df = pd.DataFrame({
        "path_signal": [os.path.join("data", "EM_low.tif")],
        "path_target": [os.path.join("data", "MBP_low.tif")],
    }).rename_axis("arbitrary")
    if not train:
        df = add_augmentations(df)
    return TiffDataset(dataframe=df)
Exemplo n.º 5
0
def dummy_custom_dataset(train: bool = False) -> TiffDataset:
    """Returns a dummy custom dataset."""
    df = pd.DataFrame({
        'path_signal': [os.path.join('data', 'EM_low.tif')],
        'path_target': [os.path.join('data', 'MBP_low.tif')],
    })
    if not train:
        df = add_augmentations(df)
    return _CustomDataset(df)
Exemplo n.º 6
0
def dummy_fnet_dataset(train: bool = False) -> TiffDataset:
    """Returns a dummy Fnetdataset."""
    df = pd.DataFrame({
        'path_signal': [os.path.join('data', 'EM_low.tif')],
        'path_target': [os.path.join('data', 'MBP_low.tif')],
    }).rename_axis('arbitrary')
    if not train:
        df = add_augmentations(df)
    return TiffDataset(dataframe=df)
Exemplo n.º 7
0
def testdataset(train: bool) -> TiffDataset:
    """Dummy dataset for testing."""
    path_data_dir = os.path.join(os.path.dirname(fnet.__file__), os.pardir,
                                 'data')
    df = pd.DataFrame({
        'path_signal': [os.path.join(path_data_dir, 'EM_low.tif')],
        'path_target': [os.path.join(path_data_dir, 'MBP_low.tif')],
    })
    if not train:
        df = add_augmentations(df)
        df = df.iloc[1:, :].reset_index(drop=True)
    return TiffDataset(dataframe=df)
Exemplo n.º 8
0
 def __init__(
     self,
     col_index: Optional[str] = None,
     col_signal: str = 'path_signal',
     col_target: str = 'path_target',
     augment: bool = False,
     **kwargs,
 ):
     super().__init__(**kwargs)
     assert col_signal in self.df.columns
     assert col_target in self.df.columns
     self.col_index = col_index
     self.col_signal = col_signal
     self.col_target = col_target
     self.augment = augment
     if self.col_index is not None:
         self.df = self.df.set_index(self.col_index)
     if self.augment:
         self.df = add_augmentations(self.df)