04-23-2013 05:59 AM
Hi,
I am trying to automate processing of my channels, but as a first step I need to crop them within specific boundaries (all data at once).
Kindly let me know any specific script commands which would help me in doing the same.
Solved! Go to Solution.
04-23-2013 10:26 AM
Hi faz_mah,
You will need to more fully describe the desired work flow. Will a user select the region of interest in a VIEW graph with the X band cursors or the XY frame cursor, or will the cropping region be programmatically determined? Are all the channels that should be cropped together the same length? Do you have XY data channels or are you using waveform channels? Do you want to set the values outside the region of interest to NoValue or do you want to delete those values? Do you want to retain the original data in DIAdem along with the cropped data so that a user could crop out multiple regions?
What do you want to do with the region of interest after it has been cropped?
Brad Turpin
DIAdem Product Support Engineer
National Instruments
04-23-2013 10:37 PM
Hi Brad_Turpin,
Thanks for the immediate response.
All of my data are XY data channels plotted against time. My requirement is fixed to crop all channels together apart from 0 to x sec and delete the unwanted data points (i.e. I don't need to check the channel in VIEW graph to decide the area to be cropped). Once the the data channels have been cropped, they are then plotted together for further study.
I would like to know how to do this by both, keeping the original data in Diadem and also without keeping the original data.
Please let me know if you need more clarifications.
Regards,
faz_mah
04-24-2013 12:49 PM
Hi faz_mah,
The short answer is to use the function "DataBlDel()". If you would post one of your data sets or email it to me at brad.turpin@ni.com, I can send you a VBScript that works on your files.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
04-25-2013 03:58 AM - edited 04-25-2013 04:04 AM
Hi Brad_Turpin,
I have attached a sample data with this post for your reference. In the attached file, there is one time channel (X axis) and one data channel (Y axis), and I need to crop both the channels apart from 0 to 20 sec.
I checked the syntax for DataBlDel() which is 'Call DataBlDel(ChnNoStr, ChnRow, ValNo, [ValDelOnly])'. What I understand from this is (please correct me if I am wrong), I need to input the 'row no.' and the number of values from and to which I want to delete values from the channel data.
But the problem for using it is that the 'row no.' and the number of values I want delete may vary when I pull in a different dataset. (i.e. If you look at the attached file you can see that for this example time channels starts from -5 to 40 sec, but for a different dataset time channel may start from -10 to 35 sec. But my requirement for the new dataset still remains same, that is from 0 to 20 sec). What should I do for this condition
Additionally, I would also like to know the best way to crop if I am having more than one data channels (lets say, I am having 5 data channels apart from the time channel and want to crop all of them from 0 to 20 sec).
Hope I have not confused you, please let me know for further clarification of my requirement.
Thanks in advance.
Regards,
Fazil Shah.
04-26-2013 12:58 PM
Hi faz_mah,
Thanks for the data file. Here is the script that does what I understand you to want. I'm including the full version with resource files in the attachment below-- just detach all files to the same folder and run the VBScript in DIAdem SCRIPT.
Set Group = Data.Root.ActiveChannelGroup Set XChannel = Group.Channels(1) P0 = 1 P1 = PNo(XChannel, 0) P2 = PNo(XChannel, 20) PN = XChannel.Size Set Channels = Data.CreateElementList FOR Each Channel In Group.Channels Call Channels.Add(Channel) NEXT IF PN-P2 > 0 THEN Call DataBlDel(Channels, P2+1, PN-P2) IF P1-P0 > 0 THEN Call DataBlDel(Channels, P0, P1-P0)
Brad Turpin
DIAdem Product Support Engineer
National Instruments
04-26-2013 01:06 PM
Shoot!
Didn't need that loop, here's cleaner code:
Set Group = Data.Root.ActiveChannelGroup Set XChannel = Group.Channels(1) P0 = 1 P1 = PNo(XChannel, 0) P2 = PNo(XChannel, 20) PN = XChannel.Size Set Channels = Group.Channels IF PN-P2 > 0 THEN Call DataBlDel(Channels, P2+1, PN-P2) IF P1-P0 > 0 THEN Call DataBlDel(Channels, P0, P1-P0)
Brad
07-09-2013 02:21 AM
Hi Brad_Turpin,
Sorry for the delayed reply, I could not check the script until now.
The script is working fine with my requirements. Thanks for your efforts.
Regards,
Fazil Shah.