Skip to content

Commit

Permalink
Merge branch 'rc/2.13.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsf committed Feb 2, 2022
2 parents 0f3bc78 + c49c871 commit 7ee579e
Show file tree
Hide file tree
Showing 11 changed files with 587 additions and 9 deletions.
2 changes: 1 addition & 1 deletion allensdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#
import logging

__version__ = '2.13.2'
__version__ = '2.13.3'


try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ def from_nwb(cls, nwbfile: NWBFile,
dilation_frames=dilation_frames)

eye_tracking_data["likely_blink"] = likely_blinks
eye_tracking_data.at[likely_blinks, "eye_area"] = np.nan
eye_tracking_data.at[likely_blinks, "pupil_area"] = np.nan
eye_tracking_data.at[likely_blinks, "cr_area"] = np.nan
eye_tracking_data.loc[likely_blinks, "eye_area"] = np.nan
eye_tracking_data.loc[likely_blinks, "pupil_area"] = np.nan
eye_tracking_data.loc[likely_blinks, "cr_area"] = np.nan

return EyeTrackingTable(eye_tracking=eye_tracking_data)

Expand Down
19 changes: 14 additions & 5 deletions allensdk/brain_observatory/behavior/stimulus_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,21 @@ def get_stimulus_metadata(pkl) -> pd.DataFrame:
stimulus_index_df = pd.DataFrame(columns=[
'image_name', 'image_category', 'image_set', 'phase',
'spatial_frequency', 'image_index'])
stimulus_index_df = stimulus_index_df.astype({
'image_name': str,
'image_category': str,
'image_set': str,
'phase': float,
'spatial_frequency': float,
'image_index': int
})

# get the grating metadata will be empty if gratings are absent
grating_df = get_gratings_metadata(stimuli,
start_idx=len(stimulus_index_df))
stimulus_index_df = stimulus_index_df.append(grating_df,
ignore_index=True,
sort=False)
stimulus_index_df = pd.concat([stimulus_index_df, grating_df],
ignore_index=True,
sort=False)

# Add an entry for omitted stimuli
omitted_df = pd.DataFrame({'image_category': ['omitted'],
Expand All @@ -299,8 +307,9 @@ def get_stimulus_metadata(pkl) -> pd.DataFrame:
'phase': np.NaN,
'spatial_frequency': np.NaN,
'image_index': len(stimulus_index_df)})
stimulus_index_df = stimulus_index_df.append(omitted_df, ignore_index=True,
sort=False)
stimulus_index_df = pd.concat([stimulus_index_df, omitted_df],
ignore_index=True,
sort=False)
stimulus_index_df.set_index(['image_index'], inplace=True, drop=True)
return stimulus_index_df

Expand Down
29 changes: 29 additions & 0 deletions allensdk/brain_observatory/multi_stimulus_running_speed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Extract running speed
=====================
Calculates an average running speed for the subject on each stimulus frame.


Running
-------
```
python -m allensdk.brain_observatory.multi_stimulus_running_speed --input_json <path to input json> --output_json <path to output json>
```
See the schema file for detailed information about input json contents.


Input data
----------
- Mapping stimulus pickle : Contains information about the mapping stimuli that were
presented in this experiment.
- Behavior stimulus pickle : Contains information about the behavior stimuli that were
presented in this experiment.
- Replay stimulus pickle : Contains information about the replay stimuli that were
presented in this experiment.
- Sync h5 : Contains information about the times at which each frame was presented.


Output data
-----------
- Running speeds h5 : Contains two tables. These are:
- running_speed : rows are intervals. Columns list frame times, frame indexes, mean velocities, and the net rotations from which those velocities are calculated. Known artifacts are removed, but the data are otherwise unfiltered.
- raw_data : rows are samples. Columns list acquisition times, signal and supply voltages, and net rotations since the last timestamp.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from allensdk.brain_observatory.\
multi_stimulus_running_speed.multi_stimulus_running_speed import (
MultiStimulusRunningSpeed
)

if __name__ == "__main__":
multi_stimulus_running_speed = MultiStimulusRunningSpeed()
multi_stimulus_running_speed.process()
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import argschema
from argschema.fields import Nested


class MultiStimulusRunningSpeedInputParameters(argschema.ArgSchema):
output_path = argschema.fields.OutputFile(
required=True,
description="The location to write the output file"
)

mapping_pkl_path = argschema.fields.InputFile(
required=True,
help="path to pkl file containing raw stimulus information",
)
behavior_pkl_path = argschema.fields.InputFile(
required=True,
help="path to pkl file containing raw stimulus information",
)
replay_pkl_path = argschema.fields.InputFile(
required=True,
help="path to pkl file containing raw stimulus information",
)
sync_h5_path = argschema.fields.InputFile(
required=True,
help="path to h5 file containing synchronization information",
)

use_lowpass_filter = argschema.fields.Bool(
required=True,
default=True,
description=(
"apply a low pass filter to the running speed results"
)
)

zscore_threshold = argschema.fields.Float(
required=True,
default=10.0,
description=(
"The threshold to use for removing outlier "
"running speeds which might be noise and not true signal"
)
)


class MultiStimulusRunningSpeedOutputSchema(argschema.schemas.DefaultSchema):
input_parameters = Nested(
MultiStimulusRunningSpeedInputParameters,
description=("Input parameters the module was run with"),
required=True,
)


class MultiStimulusRunningSpeedOutputParameters(
MultiStimulusRunningSpeedOutputSchema
):
output_path = argschema.fields.OutputFile(
required=True,
help="Filtered running speed hdf5 output file."
)
Loading

0 comments on commit 7ee579e

Please # to comment.