Skip to content
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

Photometry copier #737

Merged
merged 39 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6ed03da
WIP fibrephotometry
oliche Jun 20, 2024
c472fa3
WIP photometry copiers / starters
oliche Jun 20, 2024
ccbb381
Start photometry workflow
oliche Jun 24, 2024
e728df5
photometry: start bonsai workflow script
oliche Jun 28, 2024
1360ce6
minimal set of parameters to start a photometry session
oliche Sep 17, 2024
32c9ecc
add the default bonsai path relative to home
oliche Sep 17, 2024
5f98134
debug arguement
oliche Sep 17, 2024
a309c94
bonsai executable
oliche Sep 17, 2024
63f1cb9
add documentation
oliche Sep 17, 2024
e577630
WIP copier photometry
oliche Oct 11, 2024
bcc789d
save changes to the bonsai workflow
Oct 11, 2024
732116c
add argument parser
bimac Oct 11, 2024
d49a24b
Merge branch 'photometry' of github.com:int-brain-lab/iblrig into pho…
bimac Oct 11, 2024
7e1eaf1
start_photometry_task_cmd
oliche Oct 11, 2024
34e8fda
WIP fibrephotometry
oliche Jun 20, 2024
259e380
WIP photometry copiers / starters
oliche Jun 20, 2024
ac18ce8
Start photometry workflow
oliche Jun 24, 2024
6ca90f2
photometry: start bonsai workflow script
oliche Jun 28, 2024
abd161b
minimal set of parameters to start a photometry session
oliche Sep 17, 2024
0e9120f
add the default bonsai path relative to home
oliche Sep 17, 2024
e3d02b8
debug arguement
oliche Sep 17, 2024
649a192
bonsai executable
oliche Sep 17, 2024
545152e
add documentation
oliche Sep 17, 2024
14a2205
WIP copier photometry
oliche Oct 11, 2024
3c2b4f5
add argument parser
bimac Oct 11, 2024
5a5d939
save changes to the bonsai workflow
Oct 11, 2024
fdcf2f6
start_photometry_task_cmd
oliche Oct 11, 2024
9fc2755
wip photometry UCL extraction
oliche Nov 8, 2024
cff3a9e
neurophotometrics copier init/copy collections
oliche Nov 10, 2024
4746be5
completed copy for UCL neurophotometrics
oliche Nov 11, 2024
aa44044
Merge branch 'iblrigv8' into photometry
bimac Nov 11, 2024
ff9366e
Merge branch 'photometry' of github.com:int-brain-lab/iblrig into pho…
bimac Nov 11, 2024
db9cd24
Update test_neurophotometrics.py
bimac Nov 11, 2024
347c705
make sure the description starts with device name
oliche Nov 11, 2024
6da07ff
update dependencies / add pandera
bimac Nov 12, 2024
3c43c88
fix tests
oliche Nov 12, 2024
e05594e
pin to numpy < 2.0
bimac Nov 12, 2024
7938783
Replace tkinter dialogs with CLI input prompt
bimac Nov 12, 2024
3d8eaa5
Merge branch 'iblrigv8dev' into photometry
bimac Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions devices/neurophotometrics/FP3002_digital_inputs.bonsai
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<WorkflowBuilder Version="2.8.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p1="clr-namespace:Neurophotometrics.V2;assembly=Neurophotometrics"
xmlns:io="clr-namespace:Bonsai.IO;assembly=Bonsai.System"
xmlns="https://bonsai-rx.org/2018/workflow">
<Workflow>
<Nodes>
<Expression xsi:type="ExternalizedMapping">
<Property Name="PortName" DisplayName="PortName" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p1:FP3002">
<p1:AcquisitionMode>StartPhotometry</p1:AcquisitionMode>
<p1:PortName>COM4</p1:PortName>
<p1:Regions>
<p1:PhotometryRegion>
<p1:Index>0</p1:Index>
<p1:Channel>Green</p1:Channel>
<p1:Rectangle>
<p1:Location>
<p1:X>824</p1:X>
<p1:Y>492</p1:Y>
</p1:Location>
<p1:Size>
<p1:Width>166</p1:Width>
<p1:Height>180</p1:Height>
</p1:Size>
<p1:X>824</p1:X>
<p1:Y>492</p1:Y>
<p1:Width>166</p1:Width>
<p1:Height>180</p1:Height>
</p1:Rectangle>
<p1:Name>G0</p1:Name>
</p1:PhotometryRegion>
<p1:PhotometryRegion>
<p1:Index>1</p1:Index>
<p1:Channel>Green</p1:Channel>
<p1:Rectangle>
<p1:Location>
<p1:X>703</p1:X>
<p1:Y>353</p1:Y>
</p1:Location>
<p1:Size>
<p1:Width>154</p1:Width>
<p1:Height>180</p1:Height>
</p1:Size>
<p1:X>703</p1:X>
<p1:Y>353</p1:Y>
<p1:Width>154</p1:Width>
<p1:Height>180</p1:Height>
</p1:Rectangle>
<p1:Name>G1</p1:Name>
</p1:PhotometryRegion>
<p1:PhotometryRegion>
<p1:Index>2</p1:Index>
<p1:Channel>Green</p1:Channel>
<p1:Rectangle>
<p1:Location>
<p1:X>943</p1:X>
<p1:Y>134</p1:Y>
</p1:Location>
<p1:Size>
<p1:Width>180</p1:Width>
<p1:Height>176</p1:Height>
</p1:Size>
<p1:X>943</p1:X>
<p1:Y>134</p1:Y>
<p1:Width>180</p1:Width>
<p1:Height>176</p1:Height>
</p1:Rectangle>
<p1:Name>G2</p1:Name>
</p1:PhotometryRegion>
<p1:PhotometryRegion>
<p1:Index>3</p1:Index>
<p1:Channel>Green</p1:Channel>
<p1:Rectangle>
<p1:Location>
<p1:X>767</p1:X>
<p1:Y>180</p1:Y>
</p1:Location>
<p1:Size>
<p1:Width>176</p1:Width>
<p1:Height>182</p1:Height>
</p1:Size>
<p1:X>767</p1:X>
<p1:Y>180</p1:Y>
<p1:Width>176</p1:Width>
<p1:Height>182</p1:Height>
</p1:Rectangle>
<p1:Name>G3</p1:Name>
</p1:PhotometryRegion>
</p1:Regions>
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p1:PhotometryData" />
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="FileName" DisplayName="FileNamePhotometry" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p1:PhotometryWriter">
<p1:IncludeRegions>false</p1:IncludeRegions>
<p1:IncludePlots>false</p1:IncludePlots>
<p1:IncludeVideo>false</p1:IncludeVideo>
<p1:FileName>D:\iblrigv8_data\neurophotometrics\2024-10-10\T142948\raw_photometry.csv</p1:FileName>
<p1:Suffix>None</p1:Suffix>
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p1:DigitalIOs">
<p1:Input0>true</p1:Input0>
<p1:Input1>true</p1:Input1>
<p1:Output0>false</p1:Output0>
<p1:Output1>false</p1:Output1>
</Combinator>
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="FileName" DisplayName="FileNameDigitalInput" />
</Expression>
<Expression xsi:type="io:CsvWriter">
<io:FileName>D:\iblrigv8_data\neurophotometrics\2024-10-10\T142948\digital_inputs.csv</io:FileName>
<io:Append>false</io:Append>
<io:Overwrite>false</io:Overwrite>
<io:Suffix>None</io:Suffix>
<io:IncludeHeader>false</io:IncludeHeader>
</Expression>
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="2" Label="Source1" />
<Edge From="1" To="5" Label="Source1" />
<Edge From="2" To="4" Label="Source1" />
<Edge From="3" To="4" Label="Source2" />
<Edge From="5" To="7" Label="Source1" />
<Edge From="6" To="7" Label="Source2" />
</Edges>
</Workflow>
</WorkflowBuilder>
101 changes: 101 additions & 0 deletions devices/neurophotometrics/FP3002_digital_inputs.bonsai.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<VisualizerLayout xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<DialogSettings>
<Visible>false</Visible>
<Location>
<X>0</X>
<Y>0</Y>
</Location>
<Size>
<Width>0</Width>
<Height>0</Height>
</Size>
<WindowState>Normal</WindowState>
</DialogSettings>
<DialogSettings>
<Visible>false</Visible>
<Location>
<X>0</X>
<Y>0</Y>
</Location>
<Size>
<Width>0</Width>
<Height>0</Height>
</Size>
<WindowState>Normal</WindowState>
</DialogSettings>
<DialogSettings>
<Visible>false</Visible>
<Location>
<X>0</X>
<Y>0</Y>
</Location>
<Size>
<Width>0</Width>
<Height>0</Height>
</Size>
<WindowState>Normal</WindowState>
</DialogSettings>
<DialogSettings>
<Visible>false</Visible>
<Location>
<X>0</X>
<Y>0</Y>
</Location>
<Size>
<Width>0</Width>
<Height>0</Height>
</Size>
<WindowState>Normal</WindowState>
</DialogSettings>
<DialogSettings>
<Visible>false</Visible>
<Location>
<X>0</X>
<Y>0</Y>
</Location>
<Size>
<Width>0</Width>
<Height>0</Height>
</Size>
<WindowState>Normal</WindowState>
</DialogSettings>
<DialogSettings>
<Visible>false</Visible>
<Location>
<X>0</X>
<Y>0</Y>
</Location>
<Size>
<Width>0</Width>
<Height>0</Height>
</Size>
<WindowState>Normal</WindowState>
</DialogSettings>
<DialogSettings>
<Visible>false</Visible>
<Location>
<X>0</X>
<Y>0</Y>
</Location>
<Size>
<Width>0</Width>
<Height>0</Height>
</Size>
<WindowState>Normal</WindowState>
</DialogSettings>
<DialogSettings>
<Visible>false</Visible>
<Location>
<X>0</X>
<Y>0</Y>
</Location>
<Size>
<Width>0</Width>
<Height>0</Height>
</Size>
<WindowState>Normal</WindowState>
</DialogSettings>
</VisualizerLayout>
13 changes: 13 additions & 0 deletions devices/neurophotometrics/_neurophotometrics_fpData.channels.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Condition,No LED ON,L415,L470,L560
No additional signal,0,1,2,4
Output 1 signal HIGH,8,9,10,12
Output 0 signal HIGH,16,17,18,20
Stimulation ON,32,33,34,36
GPIO Line 2 HIGH,64,65,66,68
GPIO Line 3 HIGH,128,129,130,132
Input 1 HIGH,256,257,258,260
Input 0 HIGH,512,513,514,516
Output 0 signal HIGH + Stimulation,48,49,50,52
Output 0 signal HIGH + Input 0 signal HIGH,528,529,530,532
Input 0 signal HIGH + Stimulation,544,545,546,548
Output 0 HIGH + Input 0 HIGH + Stimulation,560,561,562,564
68 changes: 68 additions & 0 deletions docs/source/usage_neurophotometrics.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Neurophotometrics recording with iblrigv8
=========================================

This document describes how to use the iblrigv8 software to record Photometry using Neurophotometrics FP3002 system.

Setup
-----

- iblrigv8 is installed according to the instructions
- `settings/iblrig_settings.yaml` file is configured with the local folder and remote folder for the data transfer.
- `settings/hardware_settings.yaml` file is configured with the neurophotometrics device

.. code:: yaml
RIG_NAME: photometry
MAIN_SYNC: False
device_neurophotometrics:
DEVICE_MODEL: NP3002
BONSAI_EXECUTABLE: C:\Users\IBLuser\AppData\Local\Bonsai\Bonsai.exe
BONSAI_WORKFLOW: devices\neurophotometrics\FP3002.bonsai
COM_NEUROPHOTOMETRY: COM3


Starting a photometry recording
--------------------------------

- Start the Bonsai workflow by running the following command in powershell:
.. code:: powershell

cd C:\iblrigv8\
venv\scripts\Activate.ps1
start_neurophotometrics
- in Bonsai click on the FP3002 node and load the desired photometry settings file
- start the task

The photometry recording will start and the photometry data will be saved in the data local folder with the following stucture:
- {local_data_folder}\neurophotometrics\yyyy-mm-dd\THHMMSS
Where yyyy-mm-dd is the date of the recording and HHMMSS is the time of the recording.



Starting a photometry session
--------------------------------

- Start the Bonsai workflow by running the following command in powershell:
.. code:: powershell

cd C:\iblrigv8\
venv\scripts\Activate.ps1
start_photometry_session --subject=Mickey --roi G0 G1 --location NBM SI



Copy command
------------

Usage
~~~~~

To initiate the data transfer from the local server to the remote server, open a terminal and type.

.. code:: powershell

C:\iblrigv8\venv\scripts\Activate.ps1
transfer_data --tag photometry

The transfer local and remote directories are set in the
``iblrig/settings/iblrig_settings.py`` file.

1 change: 0 additions & 1 deletion iblrig/base_choice_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from pydantic import NonNegativeFloat, NonNegativeInt

import iblrig.base_tasks
import iblrig.graphic
from iblrig import choiceworld, misc
from iblrig.hardware import SOFTCODE
from iblrig.pydantic_definitions import TrialDataModel
Expand Down
16 changes: 8 additions & 8 deletions iblrig/base_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from pythonosc import udp_client

import ibllib.io.session_params as ses_params
import iblrig.graphic as graph
import iblrig.path_helper
import pybpodapi
from ibllib.oneibl.registration import IBLRegistrationClient
Expand All @@ -39,7 +38,7 @@
from iblrig.hifi import HiFi
from iblrig.path_helper import load_pydantic_yaml
from iblrig.pydantic_definitions import HardwareSettings, RigSettings, TrialDataModel
from iblrig.tools import call_bonsai
from iblrig.tools import call_bonsai, get_number
from iblrig.transfer_experiments import BehaviorCopier, VideoCopier
from iblrig.valve import Valve
from iblutil.io.net.base import ExpMessage
Expand Down Expand Up @@ -617,10 +616,10 @@ def run(self):
self.create_session()
# When not running the first chained protocol, we can skip the weighing dialog
first_protocol = int(self.paths.SESSION_RAW_DATA_FOLDER.name.split('_')[-1]) == 0

# get subject weight
if self.session_info.SUBJECT_WEIGHT is None and self.interactive and first_protocol:
self.session_info.SUBJECT_WEIGHT = graph.numinput(
'Subject weighing (gr)', f'{self.session_info.SUBJECT_NAME} weight (gr):', nullable=False
)
self.session_info.SUBJECT_WEIGHT = get_number('Subject weight (g): ', float, lambda x: x > 0)

def sigint_handler(*args, **kwargs):
# create a signal handler for a graceful exit: create a stop flag in the session folder
Expand All @@ -637,10 +636,11 @@ def sigint_handler(*args, **kwargs):
log.critical('Graceful exit')
log.info(f'Session {self.paths.SESSION_RAW_DATA_FOLDER}')
self.session_info.SESSION_END_TIME = datetime.datetime.now().isoformat()

# get poop count
if self.interactive and not self.wizard:
self.session_info.POOP_COUNT = graph.numinput(
'Poop count', f'{self.session_info.SUBJECT_NAME} droppings count:', nullable=True, askint=True
)
self.session_info.POOP_COUNT = get_number('Droppings count: ', int, lambda x: x >= 0)

self.save_task_parameters_to_json_file()
self.register_to_alyx()
self._execute_mixins_shared_function('stop_mixin')
Expand Down
Loading