[features] adding features
This commit is contained in:
@@ -266,6 +266,8 @@ class StimulusToNix:
|
||||
nix_group = self.nix_file.blocks[0].groups[repro.name]
|
||||
nix_group.multi_tags.append(nix_mtag)
|
||||
|
||||
self._append_features(repro, nix_mtag)
|
||||
|
||||
def _append_tag(self, repro: rlx.Dataset, position: np.ndarray, extent: np.ndarray) -> None:
|
||||
"""Append tag of the current repro.
|
||||
|
||||
@@ -321,6 +323,45 @@ class StimulusToNix:
|
||||
nix_group = self.nix_file.blocks[0].groups[repro.name]
|
||||
nix_group.tags.append(nix_tag)
|
||||
|
||||
def _append_features(self, repro, mtag):
|
||||
s = repro.stimuli[0]
|
||||
if not s.features:
|
||||
log.debug(f"Repro {repro.name} does not have a feature in multitags")
|
||||
return
|
||||
das_names = [f[1] for f in s.features]
|
||||
for das in das_names:
|
||||
arr = self.relacs_block.data_arrays[das]
|
||||
if arr.data.dtype == object:
|
||||
data = arr.data[:].astype(np.dtypes.StringDType)
|
||||
else:
|
||||
data = arr.data[:]
|
||||
|
||||
try:
|
||||
f = self.block.create_data_array(
|
||||
arr.name,
|
||||
arr.type,
|
||||
data=data,
|
||||
unit=arr.unit,
|
||||
label=arr.label,
|
||||
)
|
||||
for d in arr.dimensions:
|
||||
if d.dimension_type == nixio.DimensionType.Set:
|
||||
f.append_set_dimension(labels=d.labels)
|
||||
elif d.dimension_type == nixio.DimensionType.Range:
|
||||
f.append_range_dimension(
|
||||
np.sort(d.ticks),
|
||||
labels=d.labels,
|
||||
)
|
||||
else:
|
||||
f.append_sampled_dimension(
|
||||
d.sampling_interval,
|
||||
labels=d.labels,
|
||||
)
|
||||
except DuplicateName:
|
||||
f = self.block.data_arrays[arr.name]
|
||||
|
||||
mtag.create_feature(f, nixio.LinkType.Indexed)
|
||||
|
||||
def create_repros_automatically(self) -> None:
|
||||
"""Create the repros form relacs with the TTL pulses."""
|
||||
ttl_oeph = self.block.data_arrays["ttl-line"][:]
|
||||
@@ -364,7 +405,7 @@ class StimulusToNix:
|
||||
time_ttl, peaks_ttl, current_position
|
||||
)
|
||||
|
||||
if "FICurve" in repro.name:
|
||||
if "FICurve_" in repro.name:
|
||||
position_mtags += 0.2
|
||||
|
||||
self._append_mtag(repro, position_mtags, extents_mtag)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import nixio
|
||||
import numpy as np
|
||||
@@ -78,7 +79,7 @@ class RawToNix:
|
||||
|
||||
efish_group = self.block.create_group("efish", "open-ephys.sampled")
|
||||
|
||||
efish_neo_data = self.neo_data[0].segments[0].analogsignals[2].load()
|
||||
efish_neo_data = self._load_neo_object("Data_ADC")
|
||||
|
||||
for i in np.arange(len(efishs)):
|
||||
log.debug(f"Appending efish traces {efishs[i]}")
|
||||
@@ -95,6 +96,14 @@ class RawToNix:
|
||||
)
|
||||
efish_group.data_arrays.append(data_array)
|
||||
|
||||
def _load_neo_object(self, name: str):
|
||||
for sig in self.neo_data[0].segments[0].analogsignals:
|
||||
if sig.name.endswith(name):
|
||||
return sig.load()
|
||||
|
||||
log.error(f"No {name} found in open ephys data")
|
||||
sys.exit(1)
|
||||
|
||||
def append_relacs_lines(self) -> None:
|
||||
"""Append relacs lines."""
|
||||
relacs = [
|
||||
@@ -129,25 +138,31 @@ class RawToNix:
|
||||
label=efish_relacs_data_array.label,
|
||||
unit=efish_relacs_data_array.unit,
|
||||
)
|
||||
if efish_relacs_data_array.dimensions[0].dimension_type == nixio.DimensionType.Sample:
|
||||
data_array.append_sampled_dimension(
|
||||
efish_relacs_data_array.dimensions[0].sampling_interval,
|
||||
label="time",
|
||||
unit="s",
|
||||
)
|
||||
elif efish_relacs_data_array.dimensions[0].dimension_type == nixio.DimensionType.Range:
|
||||
data_array.append_range_dimension(
|
||||
np.sort(efish_relacs_data_array.dimensions[0].ticks),
|
||||
label="time",
|
||||
unit="s",
|
||||
)
|
||||
for d in efish_relacs_data_array.dimensions:
|
||||
if d.dimension_type == nixio.DimensionType.Sample:
|
||||
data_array.append_sampled_dimension(
|
||||
efish_relacs_data_array.dimensions[0].sampling_interval,
|
||||
label="time",
|
||||
unit="s",
|
||||
)
|
||||
elif d.dimension_type == nixio.DimensionType.Range:
|
||||
data_array.append_range_dimension(
|
||||
np.sort(efish_relacs_data_array.dimensions[0].ticks),
|
||||
label="time",
|
||||
unit="s",
|
||||
)
|
||||
else:
|
||||
data_array.append_set_dimension(
|
||||
label="time",
|
||||
unit="s",
|
||||
)
|
||||
|
||||
efish_group.data_arrays.append(data_array)
|
||||
|
||||
def append_raw_data(self) -> None:
|
||||
"""Append Open-Ephys Raw data."""
|
||||
gr = self.block.create_group("neuronal-data", "open-epyhs.sampled")
|
||||
raw_neo_data = self.neo_data[0].segments[0].analogsignals[0].load()
|
||||
raw_neo_data = self._load_neo_object("Data")
|
||||
|
||||
log.debug("Appending raw data")
|
||||
nix_data_array = self.block.create_data_array(
|
||||
|
||||
Reference in New Issue
Block a user