Skip to content

Commit

Permalink
Merge branch 'metadata' of https://github.com/pynapple-org/pynapple i…
Browse files Browse the repository at this point in the history
…nto metadata
  • Loading branch information
sjvenditto committed Nov 20, 2024
2 parents 16de010 + fd24a86 commit 8c1ba66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions doc/user_guide/04_core_methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ print(
## Metadata
Metadata can be added to `TsGroup`, `IntervalSet`, and `TsdFrame` objects at initialization or after an object has been created.
- `TsGroup` metadata is information associated with each Ts/Tsd object, such as brain region or unit type.
- `IntervalSet` metadata is information assocaited with each interval, such as a trial label or stimulus condition.
- `IntervalSet` metadata is information associated with each interval, such as a trial label or stimulus condition.
- `TsdFrame` metadata is information associated with each column, such as a channel or position.


Expand Down Expand Up @@ -487,8 +487,9 @@ print(tsgroup.get_info("region"))
### Metadata properties
User-set metadata is mutable and can be overwritten.
```{code-cell} ipython3
print(tsgroup, "\n")
tsgroup.set_info(region=["A","B","C"])
print(tsgroup.get_info("region"))
print(tsgroup)
```

If the metadata name does not overlap with an existing class column, it can be set and accessed via key indexing (i.e. using square brackets).
Expand All @@ -514,7 +515,7 @@ tsgroup.coords = [[1,0],[0,1],[1,1]]
print(tsgroup.coords)
```

### Filtering
### Using metadata to slice object
Metadata can be used to filter or threshold objects based on metadata values.
```{code-cell} ipython3
print(tsgroup[tsgroup.unit_type == "good"])
Expand Down
2 changes: 2 additions & 0 deletions pynapple/core/interval_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ class IntervalSet(NDArrayOperatorsMixin, _MetadataMixin):
The `IntervalSet` object behaves like a numpy ndarray with the limitation that the object is not mutable.
If start and end are not aligned, meaning that:
1. len(start) != len(end)
2. end[i] > start[i]
3. start[i+1] > end[i]
4. start and end are not sorted,
IntervalSet will try to "fix" the data by eliminating some of the start and end data points.
Parameters
Expand Down

0 comments on commit 8c1ba66

Please sign in to comment.