Fix some tdms reading issues

parent e44b333e
......@@ -502,25 +502,30 @@ def read_tdms(fn):
dt = np.mean(np.diff(times))
except IndexError:
if not "Sampling Rate" in tdms_file.object().properties.keys():
dt = 1.0
if not "Sampling Rate(AI)" in tdms_file.object().properties.keys():
dt = 1.0
else:
sr = float(tdms_file.object().properties['Sampling Rate(AI)'])
if sr > 0:
dt = 1e3/sr
else:
dt = 1.0/25.0
else:
sr = tdms_file.object().properties['Sampling Rate']
sr = float(tdms_file.object().properties['Sampling Rate'])
if sr > 0:
dt = 1e3/sr
else:
dt = 1.0
chlist = [Channel(
[Section(channel.data)
for channel in tdms_file.group_channels(group)
if channel.data is not None])
for group in tdms_file.groups()
if group.lower() != "time"]
chlist[0].xunits = "mV"
chlist[1].yunits = "pA"
rec = Recording(chlist)
rec.dt = dt
rec.xunits = "ms"
sys.stderr.write(fn + "\n")
return rec
dt = 1.0/25.0
return_dict = {
"data": [
[channel.data.astype(np.float64)
for channel in tdms_file.group_channels(group)
if channel.data is not None]
for group in tdms_file.groups()
if group.lower() != "time"],
"dt": dt,
}
return return_dict
}
//--------------------------------------------------------------------
......@@ -1819,7 +1819,12 @@ void wxStfGraph::CreateScale(wxDC* pDC)
double y2First=nextTickMult*yScaled2;
int y2FirstTick=yFormat2(y2First);
// How many times does the y-scale bar fit into the window?
int y2ScaleInWindow=(y2FirstTick-topDist)/barLengthY2;
int y2ScaleInWindow = 1;
if (barLengthY2 > 0) {
y2ScaleInWindow = (y2FirstTick-topDist)/barLengthY2;
} else {
y2ScaleInWindow = (y2FirstTick-topDist)/1e-15;
}
// y-Axis ticks:
for (int n_tick_y=0;n_tick_y<=y2ScaleInWindow;++n_tick_y) {
pDC->DrawLine(leftDist*2-tickLength,
......
import numpy as np
import stf
import stfio
def tdms_open(fn):
rec = stfio.read_tdms(fn)
if rec is None:
record = stfio.read_tdms(fn)
if record is None:
return None
li = [[sec.asarray() for sec in chan] for chan in rec]
return li, rec.dt
return record['data'], record['dt']
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment