Skip to content

More fib plus pav updates #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 42 commits into from
May 28, 2025
Merged

More fib plus pav updates #293

merged 42 commits into from
May 28, 2025

Conversation

dougollerenshaw
Copy link
Contributor

@dougollerenshaw dougollerenshaw commented May 5, 2025

Summary of updates:

  • Add behavior cameras to src/aind_metadata_mapper/pavlovian_behavior/example_create_session.py
  • Improves the docstring in src/aind_metadata_mapper/pavlovian_behavior/example_create_session.py with an example CLI command.
  • Add a special case to src/aind_metadata_mapper/utils/merge_sessions.py to deal with conflicting reward units. If one session file has reward_consumed_total = null, ignore the associated units.
  • Added many missing fields in the stimulus_epochs field in src/aind_metadata_mapper/pavlovian_behavior/example_create_session.py
  • Vastly simplified scripts/example_create_fiber_and_pav_sessions.py to use the default params specified in src/aind_metadata_mapper/pavlovian_behavior/example_create_session.py and src/aind_metadata_mapper/fib/example_create_session.py
  • Added ability to pass through the following parameters from the command line:
    • active_mouse_platform
    • anaesthesia
    • animal_weight_post
    • animal_weight_prior
    • mouse_platform_name
  • Fixed incorrect timestamp format in session.json (timestamps should be in local timezone with offset, not in "Z" format)
  • Added a new "timing_utils" module to handle shared utility functions for both fib and pavlovian_behavior mappers
  • Updated the merge_sessions logic & added to the docstring to note that concept of merging sessions will go away w/ schema 2.0.

@dougollerenshaw dougollerenshaw requested a review from hagikent May 5, 2025 17:05
@dougollerenshaw
Copy link
Contributor Author

Note: this is related to this issue.

Copy link
Collaborator

@hagikent hagikent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes confirmed. Major modality specific functions tested. Bash argparse example usage tested.
Once Saskia et al. give a green light to the (tentative) design of stimulus_epoch, goo to be merged! (or merge now and later patch-fix)

hagikent and others added 12 commits May 6, 2025 18:46
The original code was mainly designed to be used for CLI/argparse via command-line. I foresee a need to use it as a standalone python function. So, this refactoring introduced the create_unified_session_metadata() while keeping the main() function at the bottom so it can be used for both usecases.
restoring help args for CLI
…dates_patch_kh

suggestion for the example code to make it a python function
@dougollerenshaw dougollerenshaw requested a review from saskiad May 7, 2025 19:53
@dougollerenshaw
Copy link
Contributor Author

Comment from Saskia: remove active_mouse_platform and anesthesia as passable params. They are not relevant here.

@dougollerenshaw
Copy link
Contributor Author

dougollerenshaw commented May 13, 2025

@hagikent, I reviewed the session.json that is produced by this code with @saskiad yesterday afternoon. She had a few questions/suggestions. Here's a subset of those that I could use some help from you in answering:

  • Are there any data acquisition boards you can specify that are used for behavior videos, behavior, or fiber? All of these are currently empty lists. They should correspond to daq names that are listed in the rig.json, which are:
    • "harp behavior board"
    • "harp sound card"
    • "harp clock synchronization board"
    • "harp sound amplifier"
    • "USB DAQ"
  • The data_stream that I have named 'behavior' should actually be 'behavior-videos'. I'll make that change. But do you have any info you can share about the software that controlled the behavior videos? Ideally a github permalink to the actual version used.
  • Do you have info on the software controlling the fiber acquisition? Again, ideally a github permalink to the actual version used
  • And same for the behavior control. Need a link to the software used to control stim delivery
  • Do the stimulus_names of the four stimuli in the stimulus_parameters (CS1, CS2, CS3, CS4) match the actual names used in code? If so, we should leave them as is. If not, Saskia was suggesting that the white noise stimulus should have a more descriptive name.

@hagikent
Copy link
Collaborator

  1. not really — videos are digitized at the level of the sensors and directly USB connected to the PC. Fiber is the same. Behavior...? Not sure if any specific behavior, but mouse lick is digitized by lick-detector (analog to TTL) or "harp behavior board" (TTL to harp-message), depending on the definition of DAQ.

  2. The same Bonsai workflow as the behavior control and FIP data acquisition.
    https://github.com/AllenNeuralDynamics/PavlovianCond_Bonsai

  3. Same as above (all integrated)

  4. Same as above (all integrated)

  5. We need those abstraction since mapping can be changed (technically CS1 can be WN instead of CS4, although we haven't done such contingency flip yet)

@dougollerenshaw
Copy link
Contributor Author

For software, I'm going to use the permalink for the version of the code after the most recent commit, which would be https://github.com/AllenNeuralDynamics/PavlovianCond_Bonsai/tree/dafd7dfe0f347f781e91466b3d16b83cf32f8b6d

Copy link

@saskiad saskiad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went over output with Doug which looks good. Haven't examine code rigorously.


def test_read_csv_safely_error_conditions(self):
"""Test CSV reading with error conditions."""
with tempfile.TemporaryDirectory() as tmpdir:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to discourage the use of writing to the user's file system during unit tests. For reading small files, we've been putting pre-made files into the test resources directory. For writes, we usually mock the write operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5dbce34!

Copy link
Contributor

@jtyoung84 jtyoung84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • If possible, please update the unit tests to mock the write operations
  • Also, in the future, please create a ticket with the proposed changes/issues before large modifications

@dougollerenshaw
Copy link
Contributor Author

Thanks @jtyoung84!

  • If possible, please update the unit tests to mock the write operations

Fixed.

  • Also, in the future, please create a ticket with the proposed changes/issues before large modifications

Will do.

Requesting re-review.

@dougollerenshaw dougollerenshaw requested a review from jtyoung84 May 27, 2025 15:14
@dougollerenshaw dougollerenshaw merged commit 160f083 into dev May 28, 2025
3 checks passed
@dougollerenshaw dougollerenshaw deleted the more_fib_plus_pav_updates branch May 28, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants