Skip to content

Commit

Permalink
Remove SessionGroup (LorenFrankLab#1106)
Browse files Browse the repository at this point in the history
* Remove SessionGroup

* Remove SessionGroup doct
  • Loading branch information
CBroz1 authored Sep 13, 2024
1 parent 6c8a566 commit 39c55db
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 177 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
<!-- Running draft to be removed immediately prior to release. -->

```python
import datajoint as dj
from spyglass.linearization.v1.main import TrackGraph

TrackGraph.alter() # Comment regarding the change
TrackGraph.alter() # Add edge map parameter
dj.FreeTable(dj.conn(), "common_session.session_group").drop()
```

### Infrastructure
Expand All @@ -20,6 +22,10 @@ TrackGraph.alter() # Comment regarding the change

### Pipelines

- Common

- Drop `SessionGroup` table #1106

- Decoding

- Fix edge case errors in spike time loading #1083
Expand Down
1 change: 0 additions & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ nav:
- FigURL: Features/FigURL.md
- Merge Tables: Features/Merge.md
- Export: Features/Export.md
- Session Groups: Features/SessionGroups.md
- Centralized Code: Features/Mixin.md
- For Developers:
- Overview: ForDevelopers/index.md
Expand Down
26 changes: 0 additions & 26 deletions docs/src/Features/SessionGroups.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/src/Features/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ Spyglass.
- [Mixin](./Mixin.md) - Spyglass-specific functionalities to DataJoint tables,
including fetching NWB files, long-distance restrictions, and permission
checks on delete operations.
- [Session Groups](./SessionGroups.md) - How to operate on sets of sessions.
11 changes: 0 additions & 11 deletions examples/cli_examples/create_session_group.py

This file was deleted.

7 changes: 0 additions & 7 deletions examples/cli_examples/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ spyglass insert-spike-sorter-parameters parameters.yaml
spyglass list-spike-sorter-parameters
```

## Create a session group

A session group is a collection of sessions that can be viewed via spyglassview.

See [session_groups.md](../../docs/session_groups.md) and
[create_session_group.py](./create_session_group.py).

## Create spyglass view

```bash
Expand Down
11 changes: 0 additions & 11 deletions src/spyglass/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,6 @@ def list_spike_sortings(nwb_file_name: str):
print(results)


@click.command(help="Create spyglass view of a session group.")
@click.argument("session_group_name")
def create_spyglass_view(session_group_name: str):
import spyglass.common as sgc

F = sgc.SessionGroup.create_spyglass_view(session_group_name)
url = F.url(label=session_group_name)
print(url)


cli.add_command(insert_session)
cli.add_command(list_sessions)
cli.add_command(insert_lab_team)
Expand All @@ -480,4 +470,3 @@ def create_spyglass_view(session_group_name: str):
cli.add_command(list_spike_sorter_parameters)
cli.add_command(run_spike_sorting)
cli.add_command(list_spike_sortings)
cli.add_command(create_spyglass_view)
2 changes: 1 addition & 1 deletion src/spyglass/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
)
from spyglass.common.common_region import BrainRegion
from spyglass.common.common_sensors import SensorData
from spyglass.common.common_session import Session, SessionGroup
from spyglass.common.common_session import Session
from spyglass.common.common_subject import Subject
from spyglass.common.common_task import Task, TaskEpoch
from spyglass.common.populate_all_common import populate_all_common
Expand Down
119 changes: 1 addition & 118 deletions src/spyglass/common/common_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from spyglass.common.common_lab import Institution, Lab, LabMember
from spyglass.common.common_nwbfile import Nwbfile
from spyglass.common.common_subject import Subject
from spyglass.settings import config, debug_mode, test_mode
from spyglass.settings import debug_mode
from spyglass.utils import SpyglassMixin, logger
from spyglass.utils.nwb_helper_fn import get_config, get_nwb_file

Expand Down Expand Up @@ -190,120 +190,3 @@ def _add_experimenter_part(
key["nwb_file_name"] = nwb_file_name
key["lab_member_name"] = name
Session.Experimenter.insert1(key)


@schema
class SessionGroup(SpyglassMixin, dj.Manual):
definition = """
session_group_name: varchar(200)
---
session_group_description: varchar(2000)
"""

@staticmethod
def add_group(
session_group_name: str,
session_group_description: str,
*,
skip_duplicates: bool = False,
):
"""Add a new session group."""
SessionGroup.insert1(
{
"session_group_name": session_group_name,
"session_group_description": session_group_description,
},
skip_duplicates=skip_duplicates,
)

@staticmethod
def update_session_group_description(
session_group_name: str, session_group_description
):
"""Update the description of a session group."""
SessionGroup.update1(
{
"session_group_name": session_group_name,
"session_group_description": session_group_description,
}
)

@staticmethod
def add_session_to_group(
nwb_file_name: str,
session_group_name: str,
*,
skip_duplicates: bool = False,
):
"""Add a session to an existing session group."""
if test_mode:
skip_duplicates = True
SessionGroupSession.insert1(
{
"session_group_name": session_group_name,
"nwb_file_name": nwb_file_name,
},
skip_duplicates=skip_duplicates,
)

@staticmethod
def remove_session_from_group(
nwb_file_name: str, session_group_name: str, *args, **kwargs
):
"""Remove a session from a session group."""
query = {
"session_group_name": session_group_name,
"nwb_file_name": nwb_file_name,
}
(SessionGroupSession & query).delete(
force_permission=test_mode, *args, **kwargs
)

@staticmethod
def delete_group(session_group_name: str, *args, **kwargs):
"""Delete a session group."""
query = {"session_group_name": session_group_name}
(SessionGroup & query).delete(
force_permission=test_mode, *args, **kwargs
)

@staticmethod
def get_group_sessions(session_group_name: str):
"""Get the NWB file names of all sessions in a session group."""
results = (
SessionGroupSession & {"session_group_name": session_group_name}
).fetch(as_dict=True)
return [
{"nwb_file_name": result["nwb_file_name"]} for result in results
]

@staticmethod
def create_spyglass_view(session_group_name: str):
"""Create a FigURL view for a session group."""
import figurl as fig

FIGURL_CHANNEL = config.get("FIGURL_CHANNEL")
if not FIGURL_CHANNEL:
raise ValueError("FIGURL_CHANNEL config/env variable not set")

return fig.Figure(
view_url="gs://figurl/spyglassview-1",
data={
"type": "spyglassview",
"sessionGroupName": session_group_name,
},
)


# The reason this is not implemented as a dj.Part is that
# datajoint prohibits deleting from a subtable without
# also deleting the parent table.
# See: https://docs.datajoint.org/python/computation/03-master-part.html


@schema
class SessionGroupSession(SpyglassMixin, dj.Manual):
definition = """
-> SessionGroup
-> Session
"""

0 comments on commit 39c55db

Please sign in to comment.