Skip to content

Commit

Permalink
some small improvmenets (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin authored Oct 29, 2023
1 parent c987a17 commit c79f9a0
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 34 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ Each conversion is organized in a directory of its own in the `src` directory:
├── clandinin_lab_to_nwb
│ ├── conversion_directory_1
│ └── brezovec
│ ├── brezovecbehaviorinterface.py
│ ├── brezove_convert_all_sessions.py
│ ├── brezovec_convert_session.py
│ ├── brezovec_metadata.yml
│ ├── brezovecimagingextractor.py
│ ├── brezovecimagininterface.py
│ ├── brezovecnwbconverter.py
│ ├── brezovec_requirements.txt
│ ├── brezovec_notes.md
Expand All @@ -85,11 +87,11 @@ Each conversion is organized in a directory of its own in the `src` directory:

For example, for the conversion `brezovec` you can find a directory located in `src/clandinin-lab-to-nwb/brezovec`. Inside each conversion directory you can find the following files:

* `brezove_convert_all_sessions.py`: convert all the sessions.
* `brezovec_convert_sesion.py`: this script defines the function to convert one full session of the conversion.
* `brezovec_requirements.txt`: dependencies specific to this conversion.
* `brezovec_metadata.yml`: metadata in yaml format for this specific conversion.
* `brezovecbehaviorinterface.py`: the behavior interface. Usually ad-hoc for each conversion.
* `brezovecnwbconverter.py`: the place where the `NWBConverter` class is defined.
* `brezovec_notes.md`: notes and comments concerning this specific conversion.

The directory might contain other files that are necessary for the conversion but those are the central ones.
* `brezovecimagingextractor.py`: contains an ad-hoc imaging extractor for this conversion. This is a Bruker extractor adapted to read data from the NiFTI files used in this conversion.
* `brezovecimagininterface.py`: the corresponding interface for the imaging extractor.
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
neuroconv
nwbwidgets
nwbinspector
16 changes: 5 additions & 11 deletions src/clandinin_lab_to_nwb/brezovec/brezovec_convert_all_sessions.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
from clandinin_lab_to_nwb.brezovec.brezovec_convert_session import session_to_nwb

# TODO: iterate over all session

# strat with:
from pathlib import Path
from typing import Dict
from clandinin_lab_to_nwb.brezovec.brezovec_convert_session import session_to_nwb

from neuroconv.tools.path_expansion import LocalPathExpander

# Define rooth path and data directory
root_path = Path("/media/amtra/Samsung_T5/CN_data/")
# root_path = Path("/home/heberto/Clandinin-CN-data-share/")
root_path = Path.home() / "Clandinin-CN-data-share" # Change this to the directory where the data is stored
data_dir_path = root_path / "brezovec_example_data"
output_dir_path = root_path / "conversion_nwb"
stub_test = True
output_dir_path = Path.home() / "conversion_nwb"
stub_test = False # Set to False to convert the full session otherwise only a stub will be converted for testing

# Specify source data
# Specify source data (note this assumes the files are arranged in the same way as in the example data)
source_data_spec = {
"imaging_function": {
"base_directory": data_dir_path / "imports",
Expand Down
15 changes: 9 additions & 6 deletions src/clandinin_lab_to_nwb/brezovec/brezovec_convert_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def session_to_nwb(
prefix = f"fictrac-{session_id}"
suffix = ".dat"
file_path = find_items_in_directory(directory=directory, prefix=prefix, suffix=suffix)
source_data.update(dict(FicTrac=dict(file_path=str(file_path))))
diameter_mm = 9.0 # From the Brezovec paper
diameter_meters = diameter_mm / 1000.0
source_data.update(dict(FicTrac=dict(file_path=str(file_path), radius=diameter_meters / 2)))

# Video
suffix = "-raw.avi"
Expand Down Expand Up @@ -148,16 +150,17 @@ def session_to_nwb(


if __name__ == "__main__":
# Parameters for conversion
root_path = Path("/media/amtra/Samsung_T5/CN_data/")
# root_path = Path("/home/heberto/Clandinin-CN-data-share/")
from pathlib import Path
from clandinin_lab_to_nwb.brezovec.brezovec_convert_session import session_to_nwb

root_path = Path.home() / "Clandinin-CN-data-share" # Change this to the directory where the data is stored
data_dir_path = root_path / "brezovec_example_data"
output_dir_path = root_path / "conversion_nwb"
output_dir_path = Path.home() / "conversion_nwb"
stub_test = True
stub_test = True # Set to False to convert the full session
session_id = "20200620"
subject_id = "fly2"

# Note this assumes that the files are arranged in the same way as in the example data
session_to_nwb(
data_dir_path=data_dir_path,
output_dir_path=output_dir_path,
Expand Down
2 changes: 1 addition & 1 deletion src/clandinin_lab_to_nwb/brezovec/brezovec_metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NWBFile:
keywords: [keyword1, keyword2]
keywords: [walking, neural Correlates, brain-wide Scale, drosophila, volumetric two-photon imaging, neural activity mapping, locomotor signals]
surgery: "Each fly was anesthetized on a chilled Peltier plate with a thermally coupled custom holder. Each immobilized fly was carefully fitted into a custom mount consisting of 3D-printed plastic and a custom cut steel shim to tightly nestle the head and thorax. To fix the fly to the mount, UV-curable glue was placed and cured on the dorsal region of the face between the eyes, and on the thorax. A saline solution was added to the dish for dissection (103 mM NaCl, 3 mM KCl, 5 mM TES, 1 mM NaH2PO4, 4 mM MgCl2, 1.5 mM CaCl2, 10 mM trehalose, 10 mM glucose, 7 mM sucrose, and 26 mM NaHCO3). Using a tungsten needle the posterior head cuticle was carefully cut and removed to reveal the whole brain (Figure S1). Dissection forceps were used to remove fat and trachea."
related_publications:
- https://doi.org/10.1101/2022.03.20.485047
Expand Down
10 changes: 3 additions & 7 deletions src/clandinin_lab_to_nwb/brezovec/brezovec_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ This is the one that was used in the experiment according to personal communicat
[Old file organization](https://github.com/ClandininLab/brainsss2/blob/main/file_organization.md)

## Pending questions
* What about the rest of the subjects / sessions? We don't have them, they provide another two in the last conversion.
* What about the video files? They are provided. Both the original and debugging.
* What about the fictrac header? They might provided. After investigation this is not as critical as it does not contain a lot of metadata but we built in the
machinery to read it in the data interface in neuroconv anyway.
* Why are the bruker files not in tiff format?
* What are the json files in the imports directory?
* Are the nifti files pre-processed in some way (are we getting the motion corrected ones?) or are they raw? They are raw.
* Confirm that the ANT algorithm is only applied at the population level and not at the session one. Yes, this is the most likely scenario so far.
* Are the nifti files pre-processed in some way (are we getting the motion corrected ones?) or are they raw? Answer: They are raw.
* Confirm that the ANT algorithm is only applied at the population level and not at the session one.
* Synchronization data missing. Waiting for response from the authors.

## General notes

Expand Down
6 changes: 3 additions & 3 deletions src/clandinin_lab_to_nwb/brezovec/brezovec_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nwb-conversion-tools==0.11.1 # Example of specific pinned dependecy
some-extra-package==1.11.3 # Example of another extra package that's necessary for the current conversion
roiextractors @ git+https://github.com/catalystneuro/roiextractors.git@8db5f9cb3a7ee5efee49b7fd0b694c7a8105519a # Github pinned dependency
neuroconv # Need to pin this down when we have a release with fictrac
roiextractors==0.5.5
nibabel==5.1.0

0 comments on commit c79f9a0

Please sign in to comment.