Skip to content

Commit a81b4df

Browse files
alejoe91mahlzahn
authored andcommitted
Set fill_gaps_strategy to None by default to force users defining one
1 parent 3a74ae4 commit a81b4df

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

neo/rawio/biocamrawio.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ class BiocamRawIO(BaseRawIO):
3333
----------
3434
filename: str, default: ''
3535
The *.h5 file to be read
36-
fill_gaps_strategy: "zeros" | "synthetic_noise", default: "zeros"
36+
fill_gaps_strategy: "zeros" | "synthetic_noise" | None, default: None
3737
The strategy to fill the gaps in the data when using event-based
38-
compression. If "zeros", the gaps are filled with 0s. If "synthetic_noise",
39-
the gaps are filled with synthetic noise. This is only relevant for
40-
event-based compression.
38+
compression. If None and the file is event-based compressed,
39+
you need to specify a fill gaps strategy.
40+
If "zeros", the gaps are filled with 0s.
41+
If "synthetic_noise", the gaps are filled with synthetic noise.
4142
4243
Examples
4344
--------
@@ -61,16 +62,7 @@ class BiocamRawIO(BaseRawIO):
6162
def __init__(self, filename="", fill_gaps_strategy="zeros"):
6263
BaseRawIO.__init__(self)
6364
self.filename = filename
64-
65-
if fill_gaps_strategy == "synthetic_noise":
66-
warnings.warn("Event-based compression : gaps will be filled with synthetic noise."
67-
" Set use_synthetic_noise to False for raw traces.")
68-
self.use_synthetic_noise = True
69-
elif fill_gaps_strategy == "zeros":
70-
warnings.warn("Event-based compression : gaps will be filled with 0s.")
71-
self.use_synthetic_noise = False
72-
else:
73-
raise ValueError("sparse_missing_data_strategy must be 'zeros' or 'synthetic_noise'")
65+
self._fill_gaps_strategy = fill_gaps_strategy
7466

7567
def _source_name(self):
7668
return self.filename
@@ -150,8 +142,21 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, strea
150142

151143
# read functions are different based on the version of biocam
152144
if self._read_function is readHDF5t_brw4_sparse:
145+
if self._fill_gaps_strategy is None:
146+
raise ValueError(
147+
"Please set `fill_gaps_strategy` to 'zeros' or 'synthetic_noise'."
148+
)
149+
if self._fill_gaps_strategy == "synthetic_noise":
150+
warnings.warn("Event-based compression : gaps will be filled with synthetic noise. "
151+
"Set `fill_gaps_strategy` to 'zeros' to fill gaps with 0s.")
152+
use_synthetic_noise = True
153+
elif self._fill_gaps_strategy == "zeros":
154+
use_synthetic_noise = False
155+
else:
156+
raise ValueError("`fill_gaps_strategy` must be 'zeros' or 'synthetic_noise'")
157+
153158
data = self._read_function(self._filehandle, i_start, i_stop, self._num_channels,
154-
use_synthetic_noise=self.use_synthetic_noise)
159+
use_synthetic_noise=use_synthetic_noise)
155160
else:
156161
data = self._read_function(self._filehandle, i_start, i_stop, self._num_channels)
157162

0 commit comments

Comments
 (0)