Skip to content

Commit 617c2e7

Browse files
committed
Add channel map test
1 parent 0bef040 commit 617c2e7

File tree

2 files changed

+184
-0
lines changed

2 files changed

+184
-0
lines changed

Diff for: configs/channel_map.xml

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<SETTINGS>
4+
<INFO>
5+
<VERSION>0.6.4</VERSION>
6+
<PLUGIN_API_VERSION>8</PLUGIN_API_VERSION>
7+
<DATE>19 Mar 2023 14:24:41</DATE>
8+
<OS>Mac OSX 13.0.1</OS>
9+
<MACHINE name="Pavels-MBP.lan" cpu_model="Apple M1 Pro" cpu_num_cores="8"/>
10+
</INFO>
11+
<SIGNALCHAIN>
12+
<PROCESSOR name="File Reader" insertionPoint="0" pluginName="File Reader"
13+
type="0" index="2" libraryName="" libraryVersion="" processorType="2"
14+
nodeId="100">
15+
<GLOBAL_PARAMETERS/>
16+
<STREAM name="example_data" description="A description of the File Reader Stream"
17+
sample_rate="40000.0" channel_count="16">
18+
<PARAMETERS/>
19+
</STREAM>
20+
<CUSTOM_PARAMETERS/>
21+
<EDITOR isCollapsed="0" isDrawerOpen="0" displayName="File Reader" activeStream="0"
22+
Type="FileReader">
23+
<FILENAME path="default" recording="1"/>
24+
<TIME_LIMITS start_time="0.0" stop_time="4999.0"/>
25+
</EDITOR>
26+
</PROCESSOR>
27+
<PROCESSOR name="Channel Map" insertionPoint="1" pluginName="Channel Map"
28+
type="1" index="1" libraryName="Channel Mapper" libraryVersion="0.1.0"
29+
processorType="1" nodeId="101">
30+
<GLOBAL_PARAMETERS/>
31+
<STREAM name="example_data" description="A description of the File Reader Stream"
32+
sample_rate="40000.0" channel_count="12">
33+
<PARAMETERS enable_stream="1"/>
34+
</STREAM>
35+
<CUSTOM_PARAMETERS>
36+
<STREAM>
37+
<CH index="0" enabled="1"/>
38+
<CH index="2" enabled="1"/>
39+
<CH index="1" enabled="1"/>
40+
<CH index="4" enabled="1"/>
41+
<CH index="3" enabled="1"/>
42+
<CH index="6" enabled="1"/>
43+
<CH index="5" enabled="1"/>
44+
<CH index="8" enabled="1"/>
45+
<CH index="7" enabled="1"/>
46+
<CH index="10" enabled="1"/>
47+
<CH index="9" enabled="1"/>
48+
<CH index="12" enabled="1"/>
49+
<CH index="11" enabled="0"/>
50+
<CH index="14" enabled="0"/>
51+
<CH index="13" enabled="0"/>
52+
<CH index="15" enabled="0"/>
53+
</STREAM>
54+
</CUSTOM_PARAMETERS>
55+
<EDITOR isCollapsed="0" isDrawerOpen="0" displayName="Channel Map" activeStream="0"/>
56+
</PROCESSOR>
57+
<PROCESSOR name="Record Node" insertionPoint="1" pluginName="Record Node"
58+
type="0" index="3" libraryName="" libraryVersion="" processorType="8"
59+
nodeId="102">
60+
<GLOBAL_PARAMETERS/>
61+
<STREAM name="example_data" description="A description of the File Reader Stream"
62+
sample_rate="40000.0" channel_count="12">
63+
<PARAMETERS enable_stream="1"/>
64+
</STREAM>
65+
<CUSTOM_PARAMETERS path="/Users/pavelkulik/Documents/Open Ephys" engine="BINARY"
66+
recordEvents="1" recordSpikes="1" fifoMonitorsVisible="1">
67+
<STREAM isMainStream="1" sync_line="0" name="example_data" source_node_id="100"
68+
sample_rate="40000.0" channel_count="12" recording_state="ALL"/>
69+
</CUSTOM_PARAMETERS>
70+
<EDITOR isCollapsed="0" isDrawerOpen="0" displayName="Record Node" activeStream="0"/>
71+
</PROCESSOR>
72+
</SIGNALCHAIN>
73+
<EDITORVIEWPORT scroll="0">
74+
<FILE_READER ID="100"/>
75+
<CHANNEL_MAP ID="101"/>
76+
<RECORD_NODE ID="102"/>
77+
</EDITORVIEWPORT>
78+
<DATAVIEWPORT selectedTab="2"/>
79+
<AUDIO sampleRate="44100.0" bufferSize="1024" deviceType="CoreAudio"/>
80+
<CONTROLPANEL isOpen="0" recordPath="/Users/pavelkulik/Documents/Open Ephys"
81+
recordEngine="BINARY" clockMode="0"/>
82+
<AUDIOEDITOR isMuted="0" volume="50.0" noiseGate="0.0"/>
83+
<FILENAMECONFIG>
84+
<PREPEND state="0" value=""/>
85+
<MAIN state="1" value="YYYY-MM-DD_HH-MM-SS"/>
86+
<APPEND state="0" value=""/>
87+
</FILENAMECONFIG>
88+
<PROCESSORLIST>
89+
<COLOR ID="801" R="59" G="59" B="59"/>
90+
<COLOR ID="804" R="241" G="90" B="41"/>
91+
<COLOR ID="802" R="0" G="174" B="239"/>
92+
<COLOR ID="803" R="0" G="166" B="81"/>
93+
<COLOR ID="805" R="147" G="149" B="152"/>
94+
<COLOR ID="806" R="255" G="0" B="0"/>
95+
<COLOR ID="807" R="0" G="0" B="0"/>
96+
</PROCESSORLIST>
97+
<UICOMPONENT isProcessorListOpen="1" isEditorViewportOpen="1"/>
98+
</SETTINGS>

Diff for: tests/channel_map.py

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import time
2+
3+
from open_ephys.control import OpenEphysHTTPServer
4+
from open_ephys.analysis import Session
5+
6+
import numpy as np
7+
8+
"""
9+
Test Name: Channel Map Recording
10+
Test Description: Verify mapped channels are re-ordered/disabled as expected.
11+
"""
12+
13+
def test(gui, params):
14+
15+
results = {}
16+
17+
# Fetch fresh data if needed
18+
if params['fetch']:
19+
20+
# Load config for this test
21+
if params['mode'] == 'local':
22+
gui.load(params['cfg_path'])
23+
24+
gui.acquire()
25+
time.sleep(params['acq_time'])
26+
gui.record()
27+
time.sleep(params['rec_time'])
28+
29+
gui.idle()
30+
31+
# Validate results
32+
show = False
33+
session = Session(gui.get_latest_recordings(params['parent_directory'])[0])
34+
35+
rec = session.recordnodes[0].recordings[0]
36+
num_samples,num_channels = rec.continuous[0].samples.shape
37+
print(f'Num channels: {num_channels} Num samples: {num_samples}')
38+
testName = "Total channels recorded"
39+
if num_channels == 12:
40+
results[testName] = "PASSED"
41+
else:
42+
results[testName] = "FAILED\nExpected: %d\nActual: %d" % (12, num_channels)
43+
44+
return results
45+
46+
47+
'''
48+
================================================================================================================================================
49+
'''
50+
import os
51+
import sys
52+
import argparse
53+
import platform
54+
55+
from pathlib import Path
56+
57+
if platform.system() == 'Windows':
58+
RECORD_PATH = 'C:\\open-ephys\\data'
59+
elif platform.system() == 'Linux':
60+
RECORD_PATH = '<path/to/linux/runner>' #TODO
61+
else:
62+
RECORD_PATH = '/Users/pavelkulik/Projects/Allen/OpenEphys/data/test-suite'
63+
64+
if __name__ == '__main__':
65+
66+
parser = argparse.ArgumentParser(description='Process some integers.')
67+
parser.add_argument('--mode', required=True, choices={'local', 'githubactions'})
68+
parser.add_argument('--fetch', required=False, type=int, default=1)
69+
parser.add_argument('--address', required=False, type=str, default='http://127.0.0.1')
70+
parser.add_argument('--cfg_path', required=False, type=str, default=os.path.join(Path(__file__).resolve().parent, '../configs/channel_map.xml'))
71+
parser.add_argument('--acq_time', required=False, type=int, default=2)
72+
parser.add_argument('--rec_time', required=False, type=int, default=5)
73+
parser.add_argument('--num_rec', required=False, type=int, default=1)
74+
parser.add_argument('--num_exp', required=False, type=int, default=1)
75+
parser.add_argument('--prepend_text', required=False, type=str, default='')
76+
parser.add_argument('--base_text', required=False, type=str, default='')
77+
parser.add_argument('--append_text', required=False, type=str, default='')
78+
parser.add_argument('--parent_directory', required=False, type=str, default=RECORD_PATH)
79+
parser.add_argument('--engine', required=False, type=str, default='engine=0')
80+
81+
params = vars(parser.parse_args(sys.argv[1:]))
82+
83+
results = test(OpenEphysHTTPServer(), params)
84+
85+
for test, result in results.items():
86+
print(test, '-'*(80-len(test)), result)

0 commit comments

Comments
 (0)