BouchardLab / nsds_lab_to_nwb

Python package to convert NSDS Lab data to NWB files.
https://nsds-lab-to-nwb.readthedocs.io/en/latest/
0 stars 4 forks source link

fix trialization #130

Closed jihyunbak closed 2 years ago

jihyunbak commented 2 years ago

Description and related issues

This grew into a large PR, but major changes are the following:

This PR closes these issues:

Checklist:

Did not run the tests in the test folder, but this branch successfully generates nwb for wn2 (RVG06_B03), tone (RVG06_B05), timit (RVG06_B08) and dmr (RVG06_B09) blocks.

jthermiz commented 2 years ago

@jihyunbak

1) I tried to run this PR on RVG16_B01 (wn2) and I'm getting 182 trials = 60 stimuli + 120 baseline + 2 extra baseline in the beginning

It looks like there is a baseline period that starts right after the stimulus. I think we want to space out the baseline farther away from the stimulus offset to ensure it's a true baseline.

I have not yet inspect whether the marks are at the correct times.

2) I also tried running this PR on a RVG16_B06 (tone) and got a similar issue -- ~50% more trials than expected due to extra baseline trials.

3) Re: "Stimulus metadata are now integrated into the metadata/resources/list_of_stimuli.yaml file in this package. The .yaml files in the metadata repo are no longer used"

Is this just a one off change or are we moving away from the metadata repo completely and integrating everthing to the nwb repo?

jihyunbak commented 2 years ago

@jthermiz Thanks for reviewing!

Re 1, 2) splitted baseline trials, that's just because I worked in terms of between-marks intervals. So when the stimulus is located in the middle of the between-marks interval, the current code creates two baseline trials before/after the stimulus, such that the post-prev-stim baseline and the pre-next-stim baseline are actually connected. But if this is inconvenient, it is simple to fix the code to create only (1 stim trial + 1 baseline trial) per mark, plus 2 optional extra baseline trials in the beginning/end of recording. I will implement this.

Re 2) the baseline trial being too close to the stimulus:

It looks like there is a baseline period that starts right after the stimulus. I think we want to space out the baseline farther away from the stimulus offset to ensure it's a true baseline.

This is a really good point, I just don't have a good sense about this issue to make decisions on how far away from the stimulus the baseline should start. Let's discuss more in the Slack channel!

Re 3) Location of stimulus metadata: For now, I think I will keep the stimulus metadata file list_of_stimuli.yaml in this code repository and deprecate the old stimulus metadata in the metadata repo, for two reasons:

But the metadata repo still has the probe metadata (electrode coordinates etc.), which can stay away from the codebase.

jthermiz commented 2 years ago

Sounds good @jihyunbak.

Closing the loop on 2). For the discrete stimuli like white noise and tone, there appears to be consensus for this:

The baseline trial centered about this point:

baseline center = stim offset + (next stim onset - stim offset)/2 And that baseline duration = stimulus duration

@JesseLivezey also said:

jihyunbak commented 2 years ago

Thanks @jthermiz! Follow-up:

Baseline fixes:

Additional changes: