01-15-2016 02:19 AM
Thank you very much for the help, did not think that the problem in such detail.
It remains to figure out how to do that every time the signal is read from the file .txt. I bet on the problem, but can not solve it
01-15-2016 07:49 AM
@ZORGa wrote:
Thank you very much for the help, did not think that the problem in such detail.
It remains to figure out how to do that every time the signal is read from the file .txt. I bet on the problem, but can not solve it
I'm sorry, but I don't understand what you mean. I showed you that your code can be fixed so that it makes pulses like the ones in my figure. If this is not what you want, then what do you want? You mention "every time the signal is read from the file" -- what does this mean? What is the format of the file? Does the file contain sampled data that you want to display? Does it contain a list of times that you want to create a simulated EKG waveform?
Take your time, write a more detailed and careful description of what you are trying to do.
Bob Schor
01-15-2016 10:46 AM - edited 01-15-2016 10:50 AM
I understood you. Generally case. The signal that has turned the picture, thanks to your tip, this one during cardio.
There are 4 data array, where each column - corresponding period of cardio.
(based on the pictures, you should get 11 different periods)
That I can not implement a program to the data (which is based on the Arrays cardio) read from a single file (such as TXT format)
infinitely grateful for your help and compassion
01-15-2016 03:10 PM
Sorry, all I could see was a blur. If you have several files that are easily viewed, zip them together and attach the Zip file, then I (and others) will be able to open it with our favorite viewer and maybe understand what you are trying to do.
BS
01-15-2016 05:24 PM
It turns out: we have 4 txt file format, which set parameters required for building cardio (each column of the array is the corresponding period of the chart) How to apply for their Gaussian impuls.vi to output turned cardiogram chart?
I do not know how else to describe the details of your problem ...
01-15-2016 11:55 PM
OK, so now explain the files A, tm, s1, and s2. I know that these file names match the parameters of the Gaussian Impulses you are generating, but I'm puzzled by the arrangement of numbers in these files. I see nine rows of three numbers, with the final row being three zeros. I'm guessing (but am not sure) that each row represents a PQR complex formed by summing the Gaussian impulses created by the three sets of A, tm, s1, and s2 values. But why are there 8 rows and a zero row? What is it that you want to do with these multiple rows?
Here's what I've got so far -- I've taken your Impulse Parameter Cluster (with A, tm, s1, and s2 values) and created a TypeDef from it. I've written a function that takes "t" and an Impulse Parameter Cluster as inputs and returns an Impulse Value. I'm working on a routine to read the A, tm, s1, and s2 files and create an Array structure of Impulse Parameter Clusters, but as the first paragraph suggests, I'm uncertain whether this should be a 1D or 2D array, and what the dimensions signify.
The final question is what do you want as a simulation? I see some strange code going into your ecg VI, but despite reading your VI's documentation (what? there's no documentation?), I wasn't sure what you intended. How does timing of the beats work? Are there supposed to be 8 different waveforms? If so, how do you choose which to use (or are they mixed together somehow)?
This is kind of fun -- too bad I have no idea what I'm supposed to be doing ...
Bob Schor
01-16-2016 08:10 AM
I understand you, I'm sorry that misled you. In general, I'm working on a study of diagnostic abilities of cardio in the phase space. Initially, cardio been digitized to produce a plurality of coordinates, through which this signal has been reproduced by mathcad. After that, it was compared the digitization signal and obtained by the Gaussian approximation and conducted many more stages of the study of these signals.
My goal was this: I wanted to try to simulate the digitization of the signal in the amplitude-frequency dependence, in real time (had to get 8 periods, but I understand there was an error in digitization, as the last line in which all zeros is the end of the 8 periods after the signal has to be repeated again). Null string, in principle, can be removed. Since I was first confronted with labview, I decided to start with the stage of construction of this type of signal, and then try to build a relationship in the phase space (the algorithm is very similar, just different formula VI file on which a graph). In the end, faced with anchor text data file to the construction schedule and decided to take your advice.
The final result of my request on this forum, I saw something like this: there is a certain field where it is possible to download the file "data" to read (for example it could be ID of ill patient), after loading the file is modeling cardio in real time (sequentially moving pulses, strictly in the order as the rows are arranged), or something
with respect, ZORGa
01-16-2016 11:46 PM
Zorga,
I think I figured out what you were doing, and have come up with what I think is a solution for you. However, you'll need to do a little work, yourself, as I'm going to present some of what I've done, using LabVIEW 2015, and "showing pictures" (which I complain a lot about others doing when they ask for help). The main reason for doing this is to force you to re-code this for yourself in LabVIEW 2014 (which seems to be what you are using) -- by doing this yourself, you can "play" with the code and figure out not only what I did, but possibly even why I did it, and, in the process, learn more about LabVIEW (which will serve you well as you continue with your Cardio Simulation studies),
Before diving into the code, there are some broader comments I want to make. First, a Project such as this should always be done using a LabVIEW Project. In my case, all of the code lives inside a Project named EKG Demo. LabVIEW Projects are very helpful for keeping code organized and linked in memory -- it also subtly nudges you to organize the VIs and Typedefs neatly inside your LabVIEW Folder, preferably inside a Project-specific EKG Demo folder.
When thinking about a Simulation, it is often useful to organize the Simulation Parameters (which you call A, tm, s1, and s2) together -- in my case, I created a LabVIEW Cluster, shown here:
This is saved as a Typedef. You'll notice that I gave this TypeDef its own Icon -- you'll see this again when the Cluster Constant appears on the Block Diagram of the sub-VI reading in the data files.
The organization of Parameters represented by the Cluster should probably also carry over to the organization of the Parameter Files. I actually had the most difficulty in creating these Clusters from the four files you provided. Instead of organizing the data by "features" (what I called Impulse Params) or Spikes (an array of Input Params that defines a waveform), you had all of the A parameters in one file, all of the tm parameters in another, and so on. Furthermore, the data were in a 2-D "spreadsheet" format, and it wasn't clear what the rows and columns represented. I actually made a mistake, thinking you had 8 different waveforms characterized by three parameters (since you had 8 rows of 3 columns -- I deleted the unneeded Zero entry), but figured out that you really had three waveforms with 8 parameters. [I was "led astray" by your earlier example showing P, Q, and R waveforms, 3 in number, but when I compared the values from that earlier demo with the numbers in the files, I realized that the rows represented different parameters, and the columns were the spikes. This is, again, an "illogical" order (I'm giving away my English language bias for reading left-to-right, then top-to-bottom) -- I would have expected each row to contain all of the parameters for a single Waveform, with different rows corresponding to different waveforms.
But never mind. Here is the code for Get EKG Spikes that I used to read the four data files and organize all of the parameters into a 3-row, 8-column array of Impulse Params:
The first loop reads each of the files, building their names from the Array of Strings going into the For loop. There's a Read from Spreadsheet File that's slightly modified in LabVIEW 2015 which gives, say, all of the "A" parameters in a 3 by 8 array. I reshape this into a 1D row, as I need to do some fancy Array manipulations to get it into the format I want.
What comes out of the Loop is an array of all the A, tm, s1, and s2 params in a 4 by 24 (= 3 by 😎 array. What I want is a 3D array, the first index being the Waveform index (i.e. 0 .. 2), the second being the Impulse Parameter number (i.e. 0 .. 7), and the last being the parameters, themselves (A, tm, s1, s2). The manipulations between the two For loops accomplish this rearrangement (you can verify this for yourself by putting in probes or Indicators, adding Array Size functions, etc. when you build and test this code). The final loop indexes first over the Waveform, second over the set of Impulse Params, and finally the four parameters are stuffed into the Impulse Param cluster (check out the Cluster icon) and automatically assembled into the desired 3 by 8 array by the output indexing tunnels.
Great. Now for the Top Level VI. Here is its Front Panel:
I put some simple controls to set the Heart Rate (silly me -- I forgot that 80 is beats per minute, not per second, the first time I coded it) and, just for fun, a slider to add a (normally-distributed) random change to the R-R interval. As you did, my simulation rate is 1KHz (a new point every millisecond), and I have a "SlowDown" control that determines how many milliseconds I display each millisecond of generated data. Finally, there's the display (which I made a "Sweep" display, hence the red line).
The Block Diagram is here:
The first thing is to get the EKG Spike data from the files. The number of rows returned gives the count of how many waveforms there are -- we use this to create an index, starting at 0 and incrementing modulo the number of rows, and use this index to extract the row having the eight parameters that characterize this waveform. Since the simulation does one "beat" for each waveform, we compute an R-R interval (in integer milliseconds) and use it to control the inner For loop that computes each millisecond's waveform value from the 8 sets of 4 Gaussian Impulse parameters. We get the current elapsed Time from the For loop index (in milliseconds) divided by 1000 (to convert to seconds). The inner For loop uses each of the 8 sets of Impulse parameters, along with the current time, to produce a value for that component, brought out as an array, which is then summed and sent to the EKG Chart. The code inside the Gaussian Input VI is very similar to what you showed, but by "hiding" this code inside a sub-VI, I can hide details that are not necessary to understand the "big picture" of the simulation. [Hint -- sub-VIs are your Friends].
Finally, notice that there is a Stop button inside the For loop connected to a Stop Indicator -- this is called a "Conditional Stop" (note the Stop symbol inside the outer For Loop's Index In terminal) and can be used to stop the loop early. The same wire is brought out through a tunnel and used to also stop the While loop.
You'll notice that the Block Diagrams are "neat" -- straight wires, not a lot of empty space, obvious left-to-right data flow, easily fits on a single Monitor screen (even for a laptop). There's no way to do this without sub-VIs! Note, also, the "simple-minded" Icons (just a few lines of text) that further serve as a form of "self-documentation" for the code ("What does that yellow box on the left do? Oh, it's used to "Get EKG Spikes", whatever that means ..."). Try to apply some of these ideas (which I learned from Peter Blume's "LabVIEW Style Book") to your code -- you'll find the (minimal) time investment pays big dividends!
Bob Schor
01-17-2016 12:04 AM - edited 01-17-2016 12:11 AM
also there is free tool kit with name of biomedical that you could find some simulation of signal like cardio simulation