-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create epochs on-the-fly when loading data if data has no previous epoch information #2041
Conversation
|
Issues: WB Formulas in nwb2_H17.03.016.11.09.01.nwb Determine if insert TP was on in sweep 0 |
1839466
to
0733bac
Compare
3965176
to
a1a5525
Compare
0733bac
to
baa9234
Compare
d88f4ff
to
2eb091f
Compare
@t-b How should the new feature coupled to the rest of MIES? I currently have the fallback mechanism in BSP for displaying epochs in the SB/DB and the AB function to load Sweeps and Stimsets. Should there be a button for that in the AB or do we replace a button in the AB with loading both? Also, what should be the update mechanism for the LBN and when do we apply that? |
baa9234
to
2400409
Compare
I've chatted with Tim about this and here is our conclusion:
We can do that in another PR given that this PR is self-contained with tests. |
We also would like to have retrofitted epoch info for data loaded into the databrowser/sweepbrowser (aka on-the-fly creation) either for SweepFormula or for display. Should probably be cached for speed reasons. But this should only be done if we don't have any epoch info at all. |
e294ae7
to
c48ea8a
Compare
c48ea8a
to
c9c92e1
Compare
Thanks for the massive effort: Review: 809d902 (WB: Better handling of errors when building a stimset, 2024-03-08)
cef5c04 (WB: Do not ASSERT in WB_StimsetHasLatestNoteVersion for non-existing stimset, 2024-03-21) Makes sense f51fc94 (WB: Transfer notes of stimset sweeps earlier in WB_GetStimset, 2024-03-21)
71eb1b0 (EP: Add error handling if certain required values are missing, 2024-03-08)
e0472f7 (DC: Recreation workaround for missing samplingInterval and baselineFrac, 2024-03-08)
DC_RecreateDataConfigurationResultFromLNB_baselineFrac_Path2:
s.baselineFrac and friends to NaN if the following case is hit?
e4e82b7 (DC: Evaluate if the recreated stimset had an error condition, 2024-03-08) Makes sense. c0fb94c (DC: Better error messages for invalid stimsets after recreation by WB, 2024-03-12) Nice! eb56bab (DC: More flexible TP finding as fallback, 2024-03-12)
24043f3 (DC: Add fallbacks in recreation for MIES version < 0.7, 2024-03-20)
4faf20c (DC: Add fallback for DataConfigurationResult recreation if no stimset wave is present, 2024-03-27) Makes sense. e9612a8 (AB: Introduce button to load all stimsets and sweeps for the selected entries, 2024-03-08)
3ba1af6 (EP: Change ASSERT to error return in EP_AddEpochsFromStimSet, 2024-03-12) Fine! c9c92e1 (Integrate epoch recreation in MIES, 2024-03-08) I'm not particular fond of the TS/nonTS variants of EP_FetchEpochs but I also don't see another way.
|
|
c9c92e1
to
af6ecf0
Compare
s.baselineFrac is set to NaN when the first LNB read attempt is done unsuccessful in |
c63776a
to
09bbaf8
Compare
Better handling for Custom Wave for stimset epoch can not be resolved - Previously in that case the wavebuilder just added the previous segment to the stimset wave again, whatever that was, as well as the length information. Thus, both was wrong and it resulted in a wrong stimset. Fix: - Initialize the segment to zero size at the start of the custom wave part, such that no garbage is added to the stimset. However, the stimset is still wrong as it is impossible to retrieve missing data. - Add only size information for stimset segment, if there the segment has an actual size. - As a missing custom wave is a not fixable error, introduce a field in the stimset note to store this information: STIMSET_ERROR_KEY When set then the stimset data and wave length is invalid. The stimset note is OK. Improve error output for missing custom waves from stimset segments Add failed COMBINED segments to error return code in stimset note
…stimset This allows to WB_CreateAndGetStimset to return a null wave for a stimset name that does not exist.
This change enables to have the stimset note available if the stimset is zero sized, e.g. due to failing segment creations. Error information can be retrieved then from the stimset note.
- if stimset size can not be determined from stimset epochs, try to use stimset size in data wave from s.setLength, if that also fails, abort early adding stimset epochs - if stimset epoch adding fails, do not try to add baseline trail as it depends on knowing the stimset size - if stimset epoch adding fails use a weaker limit of inf for the end of oodDAQ regions
- for samplingInterval the first DA sweep is retrieved and DimDelta is used - if baselineFrac is missing, but s.onsetDelayAuto is > 0 then find edges in this range, as it indicates a onset due to TP insertion. Use edge positions to fill TP information and recreate TP wave.
- Use workaround to calculate setLength from the stimset wave only if the stimset recreation was good
The very early MIES versions did not store the offset of the stimset in the DA wave. The offset is required for epoch recreation because it allows to split the DA wave into the onset, stimset and trail region. 1. Added a fallback algorithm that exploits the fact that the trail is a zero line. So the position of the last feature of the DA wave is matched against the last feature of the decimated stimset. Then the decimated stimset is compared to the DA wave content in a -2 to +2 range from the initial guess. If that fails then the whole range from 0 to the initial guess is searched for an optimal match between decimated stimset and DA wave content. The intense search is time consuming and a "last option" fallback. Checking available test data it was never required, so it should be a very rare case if necessary (or may hint to a flaw in the method for the initial guess). 2. For the special case that the stimset itself is a zero line, the DA wave is checked if there is a feature, that can only be a TP. From that TP and its baseline symmetry the offset of the stimset start is determined.
… wave is present - this case happens only in testing where the LNB is filled partially
… entries - for epoch recreation loading both is required.
adds a generic function to return a sweeps data folder for a DB or SB window and a given sweep number.
- The recreation of epochs is by design not threadsafe, e.g. due to stimset recreation that can include a combine epoch, where a formula is executed with Execute. Thus, EP_FetchEpochs was split to have a separate threadsafe function that does not include epoch recreation. As epoch recreation requires to know the sweepDF to retrieve the DA waves, support for this argument was added in the call chain. - BSP (SB/DB) and SweepFormula support epochs from recreation - Exporting data to NWB does not support recreation as that module runs threadsafe.
…NNELS The algorithm was only taking channels into account in the range up to NUM_DA_TTL_CHANNELS, but NUM_AD_CHANNELS is larger, such that channels > 7 were missed. Corrected the indexing and the following lookup for the headstage of the AD channel. since 2eaa70d (DC: Add function to recreate DataConfigurationResult structure from LNB, 2024-02-21)
…ld experiment file
09bbaf8
to
c45f7a6
Compare
Thanks for the adaptations. LGTM. |
Idea for missing custom waves
Some files have missing custom waves for stimset recreation.
If these custom waves stimset epochs are neighboured by square epochs with amplitude 0 (check in stimset note) and assusimg the custom waves have a non-zero amplitude, these can be found in the DA wave.
From that the length can be determined and the stimset note updated.
This can be done for each custom wave from left to right until the length of all stimset epochs is present.
(How precise the intermediate backward transformation from data wave to stimset indices is, has to be determined)
Idea for missing TP information on very early MIES data
Resample recreated stimset to a temp data wave and match that with existing DA wave.
Determine TP + onsetUser as well as termination delay from there.
close #2008
requires #2015