Skip to content

Commit 1c61e26

Browse files
committed
Add scaling factor to fix mean_waveforms and CSD.
1 parent ef35a6c commit 1c61e26

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

allensdk/brain_observatory/ecephys/_current_source_density.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ def channel_locations(self) -> np.ndarray:
5050

5151
@classmethod
5252
def from_json(cls, probe_meta: dict) -> "CurrentSourceDensity":
53+
scale = probe_meta.get("scale_mean_waveform_and_csd", 1)
5354
with h5py.File(probe_meta['csd_path'], "r") as csd_file:
5455
return CurrentSourceDensity(
55-
data=csd_file["current_source_density"][:],
56+
data=csd_file["current_source_density"][:] / scale,
5657
timestamps=csd_file["timestamps"][:],
5758
interpolated_channel_locations=csd_file["csd_locations"][:]
5859
)

allensdk/brain_observatory/ecephys/_units.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def from_json(
4747
)
4848
mean_waveforms = _read_waveforms_to_dictionary(
4949
probe['mean_waveforms_path'],
50-
local_to_global_unit_map
50+
local_to_global_unit_map,
51+
mean_waveform_scale=probe.get('scale_mean_waveform_and_csd', 1)
5152
)
5253
spike_amplitudes = _read_spike_amplitudes_to_dictionary(
5354
probe["spike_amplitudes_path"],
@@ -132,6 +133,7 @@ def _read_waveforms_to_dictionary(
132133
waveforms_path,
133134
local_to_global_unit_map=None,
134135
peak_channel_map=None,
136+
mean_waveform_scale=1,
135137
):
136138
""" Builds a lookup table for unitwise waveform data
137139
@@ -146,6 +148,8 @@ def _read_waveforms_to_dictionary(
146148
Maps unit identifiers to indices of peak channels. If provided,
147149
the output will contain only samples on the peak
148150
channel for each unit.
151+
mean_waveform_scale : float, optional
152+
Divide out a scaling from the mean_waveform. Default 1.
149153
150154
Returns
151155
-------
@@ -171,7 +175,7 @@ def _read_waveforms_to_dictionary(
171175
if peak_channel_map is not None:
172176
waveform = waveform[:, peak_channel_map[unit_id]]
173177

174-
output_waveforms[unit_id] = np.squeeze(waveform)
178+
output_waveforms[unit_id] = np.squeeze(waveform) / mean_waveform_scale
175179

176180
return output_waveforms
177181

allensdk/brain_observatory/ecephys/write_nwb/schemas.py

+10
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@ class Probe(RaisingSchema):
204204
help="""amplitude scale factor converting raw amplitudes to Volts.
205205
Default converts from bits -> uV -> V""",
206206
)
207+
scale_mean_waveform_and_csd = Float(
208+
default=1,
209+
allow_none=True,
210+
help="""Amount to scale the mean waveform and CSD by. (data / scale).
211+
This is a fix for a set of data documented in the change log.
212+
The values for unit amplitudes were changed in the input_json
213+
file and do not use this scale.
214+
If the data in LIMS for these sessions is updated, this scaling
215+
is not needed. Default is 1"""
216+
)
207217

208218

209219
class InvalidEpoch(RaisingSchema):

0 commit comments

Comments
 (0)