Closed YudiXie closed 6 years ago
Apologies that this isn't documented. You can load in the data with a function like this,
import numpy as np
def load_nidaq_data(filename, nch=2, dtype='<f8'):
with open(filename, "rb") as file_read:
dat = np.fromfile(file_read, dtype)
nidaq_dict = {}
for i in range(nch-1):
nidaq_dict['ch{:02d}'.format(i)] = dat[i::nch]
nidaq_dict['tstep'] = dat[nch-1::nch]
return nidaq_dict
nch
is the number of channels you recorded. Basically the data is streamed to little endian 32 bit floats. Bytes are written from each channel in series, so ch1--time1 | ch2--time1 | ch3--time1 | timestamp1 | ch1--time2 | ch2--time2 | ch3--time2 | timestamp2
. The function above reads in the bytes, then sort everything into a dictionary for convenient access. The timestamps are timestamps from the National Instruments board clock, which are also copied to depth_ts.txt
in the second column (here, the first column contains timestamps from the camera, and the second column contains the nearest NIDAQ timestamp). Use the second column to align data from the National Instruments stream to the Kinect stream.
It works for us! Thank you so much!
Glad to hear it! Just added to the wiki for future reference,
That's great! Thanks!
I'm a MoSeq user in Uchida Lab. We are currently testing fiber photometry with MoSeq. In our experiments we have two fiber photometry channels and they are connected to different NI-DAQ analog input channels.
When doing recording, I just Control click to select those two channels and then start session. After recording, I have a
nidaq.dat
file. How can I read this file? Are those two channels save in the same file? How can I synchronize those data with depth stream?