matnwb icon indicating copy to clipboard operation
matnwb copied to clipboard

[Feature]: Autoload TimeSeries data with offset, conversion and channel_conversion

Open nmarkowitz opened this issue 3 years ago • 0 comments

What would you like to see added to MatNWB?

Hi,

Instances of TimeSeries and children classes have additional fields added that specify how to properly load data. It would be useful if the load function(s) can automatically apply the operations expected to be performed.

Is your feature request related to a problem?

No response

What solution would you like?

Here's an example of how this could work for backwards compatibility. If any new fields are added in the future or to a child class of TimeSeries then they can just be stacked in the cfg variable and placed in the correct place of the operation on the bottom.

fname = '/Users/sportsnoah14/Documents/Northshore_Hosptial/HBML/PROJECTS/Movies/sub-NS174_ses-implant02_task-DespMeEng_ieeg.nwb';
nwbfile = nwbRead('myfile.nwb');

ts = nwbfile.resolve('/acquisition/test_ts');
p = properties(ts);
data = ts.data.load;

cfg = [];
cfg.channel_conversion = ones(size(data,1), 1);;
cfg.offset = 0;
cfg.data_conversion = 1;
operation_fields = fieldnames(cfg);
for ii = 1:length(operation_fields)
    op = operation_fields{ii};
    if any( strcmp(op, p) )
        if ~isempty( ts.(op) )
            cfg.(op) = ts.(op);
        end
    end
end

data = data*cfg.data_conversion.*cfg.channel_conversion + cfg.offset;

Do you have any interest in helping implement the feature?

Yes, but I would need guidance.

Code of Conduct

nmarkowitz avatar May 09 '22 20:05 nmarkowitz