VICTOR wrote in message
news:50650000000500000092370000-993342863000@exchange.ni.com...
> questions and will need your help. On the issue of liability in
> clinical use, I want to inform you that this work is still in the
> simulation process and will go through a lot of testing before
> clinical use.
That was a somewhat tongue in cheek comment 🙂
> Some of my immediate problems are as follows:
> 1. I need to write my data to a spreadsheet and the to be able to
> replay it at any time.
It would be quite a big task to take the code you posted and allow data to
be saved and loaded from disk for "offline" use as well as with the DAQ.
It's certainly possible, but I don't have the time to draft it, and given
that you have a very short length of time remaining on your project and you
don't seem incredibly adept at Labview coding, I'd suggest thinking
carefully about whether you can achieve this aim.
I can of course always be contracted but that would be using a sledgehammer
to crack a nut. 🙂
Is it really necessary in any case? Surely all that's important is the slope
of the graph. If the operator can go back and obtain whatever desired
numbers from the same initial dataset by tweaking front panel controls until
it looks right, there's something wrong with the idea of using this for
clinical diagnosis.
If it is really necessary to go ahead with the offline/online approach, I'd
suggest making a new sub-VI to replace the AI Acquire Waveforms.vi. The new
sub-VI should have the same inputs as the AI VI with the addition of a
filepath, an "initialise" boolean and a "mode" input. Inside the new VI is a
case structure controlled by the "mode" parameter. If you're in online mode,
you simply call the AI VI and the program is as it is now. In offline mode,
you have a while loop with a Boolean wired to the conditional such that it
only runs once. You use the "Read from Spreadsheet File" VI to retrieve one
row at a time from the input file, by wiring "1" to the number of rows. You
feed the optional "start of read offset" terminal from either the left
terminal of an uninitialised shift register, if "init" is false, or from a
zero constant if "init" is true, and you feed the "mark after read" to the
right terminal of the shift register. Do the appropriate checks for file not
found, end of file reached etc.
Saving the data initially is quite a bit easier; there's a function "Write
to Spreadsheet File" that takes an array and saves it to a file; if a
boolean input is true then it adds the new data as additional rows without
killing previous data. If you're going to use the approach I outline in the
previous paragraph you need in some way to squash your data into a 1D array
on each cycle, so you save a single row to the file on each pass round the
loop- shouldn't be a problem.
> 2. since i'll use the value of the slope to further calculate lung
> volume, i'll need only one stable value and not to be varying at my
> sampling rate. so what i want to do is to take samples a number of
> times before getting the average slope and go ahead to calculate lung
> vol. At the moment, because of the while loop, the slope and lung
> calculations are continuous until I stop it with the switch.
This is the nature of real data! It'll always vary; the fact it stops when
you press the "stop" button doesn't mean it's stopped varying. If you get
one reading per cycle, then simply have the program stop after a
predetermined number of cycles and take that final value. f you want to be
more "correct" then use the statistical functions to give mean and standard
deviation values for all of the cycles counted to date, updated on a
continuous basis. Or perhaps just of the past n cycles. You then have to
build the uncertainty in your measurement into your calculation of lung
volume to obtain an uncertainty in the lung volume.
> 3. I need to "draw" a straight line to indicate the slope being
> calculated, for record and argument purposes (maybe using the output
> of the linear fit vi(slope & intercept)).
There's a function vi/lib/Analysis/baseanly.llb/1D Linear Evaluation.vi that
will take the slope and offset and an array of X values and give you a
straight line.
However, I think the snippet I gave you has a "best fit" output array; this
holds the "y" values of the straight line corresponding to the "x" values
you feed into the function. Bundle these together and you get a single plot
of your line. At the moment you're feeding a single plot to the XY Graph; if
you look at the online help you'll see that you can also feed an array of
single plots to the terminal, and you get several lines plotted. So just
build an array of your two plots- data and fit- and wire that array to your
XY graph instead of the single data plot.