Skip to content

Commit d66b3c5

Browse files
committed
Fixed calculation of number of frames in to_frame and example_read_in
1 parent ed462b5 commit d66b3c5

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

example_read_in.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@
2929
dicHeader = rsm.read_in_header(filePath = filePath+fileName+".smh")
3030

3131
#grab information from the header
32-
frameN = int(dicHeader["FrameCounter"])
32+
frameN = int(dicHeader["NumberOfFrames"])
33+
frameC = int(dicHeader["FrameCounter"])
34+
frameB = int(dicHeader["StimBufPerFr"])
3335
frameH = int(dicHeader["FrameHeight"])
3436
frameW = int(dicHeader["FrameWidth"])
37+
3538
#sampRate = int(dicHeader[""])
3639

3740
#read in binary data, output is a dictionary, where each key is one channel.
@@ -40,11 +43,11 @@
4043
readChan1=True,readChan2=False,readChan3=False,readChan4=False)
4144

4245
#converting the data from serialized to frames. Only doing this for channel1
43-
frame1 = rsm.to_frame(output["chan1"],nFrames=frameN,frameHeight=frameH,frameWidth=frameW)
46+
frame1 = rsm.to_frame(output["chan1"],frameTotal=frameN,frameCounter=frameC,frameBuffer=frameB,frameHeight=frameH,frameWidth=frameW)
4447

4548

4649
#convert data from channel three to detect triggers
47-
frame3 = rsm.to_frame(output["chan3"],nFrames=frameN,frameHeight=frameH,frameWidth=frameW)
50+
frame3 = rsm.to_frame(output["chan3"],frameTotal=frameN,frameCounter=frameC,frameBuffer=frameB,frameHeight=frameH,frameWidth=frameW)
4851
indexes,trigArray1 = rsm.trigger_detection(frameData=frame3,triggerLevel=220,triggerMode=2)
4952

5053

readScanM.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ def read_in_data(filePath=None, header = None,
2727

2828
# Stimulus Buffer per Frame (aka how many frames are stored in one chunk)
2929
StimBufPerFr = int(header["StimBufPerFr"])
30-
30+
3131
#it seems that the framer counter, counts backwards, so to get the number of
3232
#frames, one needs to take the total number of frames and subtract from the counter
3333
nFrames = (int(header["NumberOfFrames"])-int(header["FrameCounter"]))*StimBufPerFr
3434

3535

36-
3736
#recording buffer (aka how much of each channel is saved before the next one
3837
#starts - necessary so that later one can sort the binary data according to the
3938
#channels)
@@ -77,7 +76,7 @@ def read_in_data(filePath=None, header = None,
7776
# of frameWidthXframeHeightXnFrames
7877
#- couldn't find this information in the header
7978
nChannels = int(len(values)/(nFrames*frameWidth*frameHeight))
80-
79+
8180

8281
#empty arrays to store data
8382
###to do: preallocate array the size of each should be (nFrames*frameWidth*frameHeight)
@@ -191,16 +190,19 @@ def read_in_header(filePath=None):
191190

192191

193192

194-
def to_frame(dataArray=[],nFrames=1,frameHeight=512,frameWidth=652):
193+
def to_frame(dataArray=[],frameTotal=2,frameCounter=1,frameBuffer=1,frameHeight=512,frameWidth=652):
195194
"""function to reshape the dataArray into frame format. Currently it only
196195
works with the direct scan mode (s shaped).Note that this function does not
197196
cut off retrace periods.
198197
199198
200-
nFrames is the number of recorded frames.\n
199+
frameTotal is the total number of frames.\n
200+
frameCounter counts backwards from frameTotal \n
201+
frameBuffer is the number of frames stored in one chunck. \n
201202
frameHeight is the number of pixels in the y axis.\n
202203
frameWidth is the number of pixels in the x axis\n"""
203-
204+
205+
nFrames=(frameTotal-frameCounter)*frameBuffer
204206

205207
c1=np.reshape(dataArray[0:nFrames*frameHeight*frameWidth],
206208
(nFrames,frameHeight,frameWidth),
@@ -226,7 +228,8 @@ def trigger_detection(frameData,triggerLevel=220,triggerMode=1):
226228
#####################
227229

228230
#drop triggers depending on trigger mode.
231+
229232
indexes=indexes[::triggerMode]
230233
#populate triggerArray with ones
231234
trigArray[indexes]=1
232-
return indexes,trigArray
235+
return indexes,trigArray

0 commit comments

Comments
 (0)