Closed rjlopez2 closed 2 months ago
Hi, so I put this together rather quickly since I primarily use MATLAB to read LabChart files. Looking back at my code I think the following would work. The main idea is that the comments are a part of a record or block. As such you need to access a record then get its comments. If this works I can update the readme to clarify.
#Where f is the file object
record_id = 1
r = f.records[record_i-1]
record_comments = r.comments
For all comments you would need something like this, I think:
all_comments = []
for record in f.records:
all_comments.extend(record.comments)
I think that's all correct. I'm not actually testing this, just writing in the browser.
Please let me know if that works or if you have any issues.
will check this out soon and come back to you. thanks for the speedy reply.
This works perfectly. Many thanks for the hint. I miss that. I have however another question. have a look a this screenshot of the begining of one example file:
I managed to read the file this way:
file = adi.read_file(r"my/file/path/example.adicht")
file_loaded: True
h: <cdata 'struct ADI_FileHandle__ * *' owning 8 bytes>
n_records: 8
n_channels: 8
records: Type::list, Len: 8
channels: Type::list, Len: 8
this is the content of the first channel:
file.records[0]
h: <cdata 'struct ADI_FileHandle__ * *' owning 8 bytes>
id: 1
n_ticks: 148000
tick_dt: 2.5e-05
comments: []
record_time: Class::adi.read.RecordTime
when I check out the comments, I do:
all_comments = []
for record in file.records:
all_comments.extend(record.comments)
len(all_comments)
597
the first comment look like this:
all_comments[0]
text: timestamp:14:16:04.572959
tick_position: 2867624
channel_: -1
id: 2
tick_dt: 2.5e-05
time: 71.6906
and these are the first 5 one:
all_comments[0:5]
[ text: timestamp:14:16:02.572959
tick_position: 2787624
channel_: -1
id: 1
tick_dt: 2.5e-05
time: 69.6906,
text: timestamp:14:16:04.572959
tick_position: 2867624
channel_: -1
id: 2
tick_dt: 2.5e-05
time: 71.6906,
text: timestamp:14:16:06.572959
tick_position: 2947624
channel_: -1
id: 3
tick_dt: 2.5e-05
time: 73.6906,
text: timestamp:14:16:08.572959
tick_position: 3027624
channel_: -1
id: 4
tick_dt: 2.5e-05
time: 75.6906,
text: timestamp:14:16:10.572959
tick_position: 3107624
channel_: -1
id: 5
tick_dt: 2.5e-05
time: 77.6906]
my question is (and sorry if this is very basic), based on the screenshot above what are exactly the values I am looking at ?
I know the text
is the actual annotation we input, and time
correspond to the actual recording time, but what about the others?
best
Ruben
Sure
tick_position
- this is the # of samples since the block start
channel
- channel the comment was added to, -1 indicates added to all channels
id
- comment number, these can be moved or deleted so they are not always in order
tick_dt
- inverse of the sampling rate for the ticks. This is based on the fastest channel so you are sampling something at 40kHz (1/tick_dt
) - this could probably be hidden but I think is used internally to calculate time
(i.e., time=tick_dt*tick_position
)
A somewhat unrelated FYI, LabChart provides an Active X interface for talking to LabChart. This can be used to get the current time, add comments, and retrieve data while the program is running. I use this for stimulus triggered averages. Unfortunately the control code I've written is in MATLAB (https://github.com/JimHokanson/labchart_server_matlab). However, if you can figure out how to make Active X calls in Python the MATLAB code may provide a roadmap for how to control LabChart with Python. More specifically I have a MATLAB GUI which sets my stimulus parameters, adds comments to LabChart, and then can be used to pull up stimulus triggered averages. I haven't posted the GUI code because it is a bit messy, but I use the LabChart server code (link above) for controlling LabChart. The GUI also controls the stimulator (https://github.com/JimHokanson/multichannel_systems_stg_matlab)
Thanks a lot for the explanation and the extra tips. Feel free to close this issue, I should be now good off with the lift you provide me. Cheers.
Is there a method to read the annotations or comments in a .adicht file? btw, thanks for this really nice package.
Cheers.