DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

interpolating between channel values

Hi Community,

I'm looking to create a series of "cycle" channels from a parent channel, where each cycle channel represents a fixed number of sequential samples of the parent channel interpolated by some fraction of an array index where (0 <= InterpWidth < 1).  I've manually coded this and it works, although slower than I'd like.  Does DIAdem have a particular funciton for doing this more quickly?

Please see the SplitCycles() routine in the attached script.

0 Kudos
Message 1 of 6
(3,322 Views)

Attached script to this post.

0 Kudos
Message 2 of 6
(3,312 Views)

Hello Chris,

 

I don't think anyone will be able to run the code you posted easily without the data file structure that the Script is based on.

 

That said, I have two suggestions for you:

 

  1. Have you tried the "Script Profiler" function in the SCRIPT panel yet? The Script profiler will show you the execution times of individual script statements. That allows you to focus on finding and improving the portions of your Script code that use the most processing time. It's a little awkward to use, but very helpful when trying to optimize Script run-times. The help system explains what to do (please check the image below for the location of the Script Profiler help pages) ...
  2. DIAdem is typically a single-core application. If you have functions that would benefit from running in parallel on multiple processors (i.e. processing multiple channels using the same function) rather than sequentially, you should have a look at the "Worker" objects in DIAdem. The help system has some examples, and you can use many workers (I have successfully used 8 workers on a 4 core processor with HyperThreading) to speed up certain math functions in DIAdem. This may not be applicable to your code, but may be helpful elsewhere in the future.

This image shows two sections of the DIAdem help system that might be useful to you:

 

ScrProf.png

 

I hope that these tips will get you a step closer to increasing your Script performance,

 

     Otmar

Otmar D. Foehner
0 Kudos
Message 3 of 6
(3,285 Views)

Hi Otmar,

Thank you for all the useful information.  From the script profiler, it looks like my script spends a lot of time reading/writing channel values if I understand this correctly.  I will try to figure out a way to streamline this process.

GetCycles v170328_B Script Profiler.png

0 Kudos
Message 4 of 6
(3,246 Views)

Hello Chris,

 

It does look like the individual channel value reading/writing is the portion of the Script that uses the largest amount of processing time in your application.

 

Have you had a look at the "Event finding" functions in the DIAdem Analysis panel? These allow you to search for definable events, and then use data block copy functions instead of individual data value copy functions, which might be able to speed up your Script considerably.

 

If you can share some data (if you prefer to not do that on a public forum, you can send them to my personal gmail account) I can take a look at that and see if using the event finder functions will give you a boost in performance. (My Gmail address is       FirstName DOT LastName AT gmail DOT com     - No middle initial in the address, or you can ZIP the data file and upload it here. TDMS format is preferred a it's compact and easy to read without an extra DataPlugin.

 

The channel event functions all start with "ChnEvent..." in DIAdem, and there are more functions in DIAdem than the ones you can access from the ANALYSIS panel dialog in DIAdem. Here is a list of the 2015 functions:

ChnEventHelp.png

 

Otmar D. Foehner
0 Kudos
Message 5 of 6
(3,227 Views)

Otmar,

Thanks to you and Brad T. for providing a much speedier verion of my SplitCycles() sub.  It's definitely more than twice as fast now on my antique computer: 

 170405 Script Profiler GetCycles.png
I attached the full script here in case it's usefule to anyone.  In this version, the original SplitCycles() sub is commented out for comparison.

Thanks,

Chris

0 Kudos
Message 6 of 6
(3,189 Views)