Skip to content

Commit

Permalink
Merge pull request #59 from AllenNeuralDynamics/add_docs
Browse files Browse the repository at this point in the history
Adding documentation on basic usage in README
  • Loading branch information
alexpiet authored Nov 14, 2024
2 parents 1ce41ea + 7e4685b commit 45d8a76
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,49 @@ To develop the code, run
pip install -e .[dev]
```

## Usage

### Accessing data from an NWB file
To load an NWB file
```
import aind_dynamic_foraging_data_utils.nwb_utils as nwb_utils
nwb = nwb_utils.load_nwb_from_filename(<filepath>)
```

To extract a pandas dataframe of trials
```
df_trials = nwb_utils.create_df_trials(nwb)
```

To extract a pandas dataframe of events
```
df_events = nwb_utils.create_events_df(nwb)
```

To extract a pandas dataframe of photometry data
```
fip_df = nwb_utils.create_fib_df(nwb)
```

By default, all of these functions adjust timestamps such that t(0) is the time of the first go cue. If you wish to disable this feature, use `adjust_time=False`

### Time alignment tools
To align a data variable to a set of timepoints and create an event triggered response use the alignment module. For example to align FIP data to each go cue:

```
import aind_dynamic_foraging_data_utils.alignment as alignment
etr = alignment.event_triggered_response(
fip_df.query('event == "<FIP channel>"'),
"timestamps",
"data",
df_trials['goCue_start_time_in_session'].values,
t_start = 0,
t_end = 1,
output_sampling_rate=40
)
```

## Contributing

### Linters and testing
Expand Down

0 comments on commit 45d8a76

Please sign in to comment.