Closed kouichi-c-nakamura closed 1 year ago
At the architecture level, I believe that it should be flexible and based on: https://github.com/juliencarponcy/trialexp/blob/master/params/tasks_params.csv
This to allow any arbitrary number of arbitrary combination of the declared events or condition for a task.
This is more in: https://github.com/juliencarponcy/trialexp/blob/d42df8479ff7e4544c4e75a9d799198a61c4648a/trialexp/process/data_import.py#L1239-L1313 Trial type computation (arbitrary like: hit abort miss) could possibly be added on the already computed xarray since all events and conditions are already presents there. Ths would create a new coordinate ("trial_type"?) which would be a categorical string variable, and of the same length as the trial_nb coordinates.
The above cited function could possibly be adapted to the xarray.
Me to write (chatgpt helped) documentation to help
I personally think that 3 trial types to start with in our current analysis is enough, as I discussed with @kouichi-c-nakamura.
In the category you describe:
Same for
Maybe so that function should take The following and consider adding 2 more categories trial_tyope like button_pressed and hit_bar_off ?
# Defime each trial type as a dictionary of conditions to be met
conditions_dict1 = {'trigger': 'hold_for_water', 'success': True, 'button_press': False, 'break_after_abort': False, 'water by spout': True}
conditions_dict2 = {'trigger': 'hold_for_water', 'success': False, 'button_press': False, 'break_after_abort': False}
conditions_dict3 = {'trigger': 'hold_for_water', 'success': False, 'button_press': False, 'break_after_abort': True}
# conditions_dict2 = {'trigger': 'hold_for_water', 'spout':False, 'valid': True, 'busy_win_timer': False, 'button_press': False}
# Aggregate all condition dictionaries in a list
condition_list = [conditions_dict1, conditions_dict2, conditions_dict3]
# Aliases for conditions
cond_aliases = ['hit','miss','abort']
Displaying hit, abort and miss as selectively defined above should be enough for plot clarity?
Open to all the above. I hope that could be of help.
Thanks, I'm kind of in the surgery, so I can't answer in detail, but for now I still maintain that the 3 categories of trials you mentioned (hit, miss, abort) are not good enough to compute success. My concern is that including button press and bar_off in success can mislead ourselves. If you can assure me and others that it's not the case (i.e. we don't have to worry about that), that would be great. Right now I don't fully understand how comute_success()
affects other things in the pipeline.
At the architecture level, I believe that it should be flexible and based on: https://github.com/juliencarponcy/trialexp/blob/master/params/tasks_params.csv
This to allow any arbitrary number of arbitrary combination of the declared events or condition for a task.
This is more in:
Trial type computation (arbitrary like: hit abort miss) could possibly be added on the already computed xarray since all events and conditions are already presents there. Ths would create a new coordinate ("trial_type"?) which would be a categorical string variable, and of the same length as the trial_nb coordinates. The above cited function could possibly be adapted to the xarray.
Me to write (chatgpt helped) documentation to help
I personally think that 3 trial types to start with in our current analysis is enough, as I discussed with @kouichi-c-nakamura.
In the category you describe:
- 2 by bar_off could be either hit, aborted, or a miss so ambiguous or need to be even more specified and hence too many trial types and too few trials
Same for
- 3 button press which could be also hit miss etc.
Maybe so that function should take The following and consider adding 2 more categories trial_tyope like button_pressed and hit_bar_off ?
# Defime each trial type as a dictionary of conditions to be met conditions_dict1 = {'trigger': 'hold_for_water', 'success': True, 'button_press': False, 'break_after_abort': False, 'water by spout': True} conditions_dict2 = {'trigger': 'hold_for_water', 'success': False, 'button_press': False, 'break_after_abort': False} conditions_dict3 = {'trigger': 'hold_for_water', 'success': False, 'button_press': False, 'break_after_abort': True} # conditions_dict2 = {'trigger': 'hold_for_water', 'spout':False, 'valid': True, 'busy_win_timer': False, 'button_press': False} # Aggregate all condition dictionaries in a list condition_list = [conditions_dict1, conditions_dict2, conditions_dict3] # Aliases for conditions cond_aliases = ['hit','miss','abort']
Displaying hit, abort and miss as selectively defined above should be enough for plot clarity?
Open to all the above. I hope that could be of help.
Yes, all the conditions are already in the xarray. We just need a way to map those conditions to a string representing trial outcome. Perhaps we can organize the trial outcome definition in a pandas dataframe/csv and store it somewhere else?
I doubt hard-coding them will be a good solution because those definitions will depend on the task the animal is doing (e.g. in some task there is no hold_for_water
event)
Thanks, I'm kind of in the surgery, so I can't answer in detail, but for now I still maintain that the 3 categories of trials you mentioned (hit, miss, abort) are not good enough to compute success. My concern is that including button press and bar_off in success can mislead ourselves. If you can assure me and others that it's not the case (i.e. we don't have to worry about that), that would be great. Right now I don't fully understand how
comute_success()
affects other things in the pipeline.
I think you are mislead a bit by the distinction between hit (arbitrary set of conditions) and success defined by compute_success(): compute_success() is just computing whether the spout was touched before the reward was delivered, but then my dictionary precise the 'hit' category as:
hit = _should include only successful trials where button_press was not pushed and the reward was delivered by 'water_byspout'
So specifically, compute_success disregard any complex logic and just say if the spout was touched prior to reward (for the ensemble of tasks where events and triggers are similar enough [see compute_success]) another important characteristic of compute_success() is that is a time-based logic.
On the other hand, a dictionary defining a trial type specify non-time-based logic and allow to further refine trial type as hit = (success Union water_by_bar_off Union non-button-pressed)
Don't know if this helps
Thanks, @juliencarponcy . I see that hit and success are defined differently in different places. They are different but similar to some extent. It sounds a bit like "double standard" to me. Couldn't this cause a problem? Like the trial numbers do not add up? Or put it another way, why do we need two different rules?
I forgot to include free_reward in the description above.
water_by_spout
)
water_by_spout
should be goodspout
as in compute_success()
, but this is not good enoughwater_by_bar_off
)
v.consec_fail_for_bar_off_water
v.consec_fail_for_free_water
button_press
)
button_press
happened after trial onset before busy_window, that should be counted as water_by_button or somethingbreak_after_abort
)@teristam
I have implemented this trial_outcome separation in my branch. Now working on the plotting part. However, one thing I noticed during the implementation is that all these conditions must be mutually exclusive (there can be only 1 outcome type per trial). And in the case where there can be more 1 type in a trial (e.g. water by spout and free water), we must determine their relative priority.
There is also one more outcome: late_reach
, the animal did not reach out during the reward window but only during the inter-trial interval.
Fixed in #45
Description
We need clearer definitions of the trial types as well as success for the analyses.
Currently, much of the pipeline relies on
compute_success()
However, the definition of success there is if water (
US_end_timer_trial_time
) is preceded by spout (spout_trial_time
). Successes includewater_by_bar_off
andbutton_press
. We can argue about this, but for most of the analysis, this is probably not good enough.To compensate for this, at the time of analysis, we defined a list of dictionaries to be more specific in the old pipeline.
How they are treated: https://github.com/juliencarponcy/trialexp/blob/d42df8479ff7e4544c4e75a9d799198a61c4648a/trialexp/process/data_import.py#L1130
How about this Dataframe?
On the other hand,
workflow\scripts\01_process_pycontrol.py
(dev
branch) creates and savedf_condtions.pkl
, which looks like this:df_condtions.pkl
has the following keys/columns:What we need
I think we should be able to define different types of categories. Each with a timestamp of trial onset.
water_by_spout
)water_by_spout
should be goodspout
as incompute_success()
, but this is not good enoughwater_by_bar_off
)button_press
)button_press
happened after trial onset before busy_window, that should be counted as water_by_button or somethingbreak_after_abort
)They can be used as a Coordinate in xArray
Questions to you!
@juliencarponcy @teristam @Rashasoliman80
compute_success()
in the pipeline? --- This can break many things