The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 script not working !!!
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

bedibra

France
35 Posts

Posted - 08/28/2017 :  10:59:43 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Dear all,
I have two scripts(in green) that I wrote and which work well when applied separately. But the problem is that when I append the second script to the first, the second is not working no more (see in red)!!
I really appreciate your help.
Thanks

nick_n

Finland
125 Posts

Posted - 08/28/2017 :  5:02:19 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

In order to catch the problem, it's good to have plain text of script. Could you provide that? Best,

Nikolay
Go to Top of Page

bedibra

France
35 Posts

Posted - 08/28/2017 :  6:34:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
// script de reduce rows
wreducerows irng:=[profiledata]vlineprofile!2 method:=mask orng:=[profiledata]"split data"!1;
// script de split data
range split2=[profiledata]"split data"!2:end;
del split2;
colsplit irng:=[profiledata]"split data"!1 method:=seq nrows:=200 rd:=[profiledata]"split data"!2;
// script de filtred
range filtred=[profiledata]filtred!2:end;
del filtred;
range split=[profiledata]"split data"!;
for(ii=2; ii<=split.ncols; ii++)
{
	range source = [profiledata]"split data"!col($(ii));
	range target = [profiledata]filtred!col($(ii));
	fft_filters (source) oy:= (target);
}
// script de analysis (exclude the last transient)
range analysis=[profiledata]analysis!2:end;
del analysis;
range timems = [profiledata]filtred!1;
range coo=[profiledata]filtred!;
for(ii=2; ii<=coo.ncols-1; ii++)
{
range r1 = [profiledata]filtred!wcol($(ii));
range r2 = [profiledata]filtred!wcol($(ii))[1:$(simax)];
range r3 = [profiledata]filtred!wcol($(ii))[$(simax):<end>];
sum(r1);
simax=sum.imax;
sum(r2);
col($(ii))[1] = timems(sum.imax)-timems(sum.imin);
col($(ii))[2] = Max(r1);
sum(r3);
smin=sum.min;
col($(ii))[3] =$(smin);
nlbegin iy:=(timems,r3) func:=Exponential nltree:=ParamTree;
nlfit;
nn=ParamTree.R0;
nlend;
Col($(ii))[4]=-1/nn;
}
//get the mean
range results=[profiledata]results!2;
del results; 
rowstats irng:=[profiledata]analysis!2:end mean:=[profiledata]results!2 sd:=<none>;
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 08/28/2017 :  7:59:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Obviously, it should be :

range r1 = [profiledata]filtred!wcol($(ii));
sum(r1);
simax=sum.imax;
range r2 = [profiledata]filtred!wcol($(ii))[1:$(simax)];
range r3 = [profiledata]filtred!wcol($(ii))[$(simax):<end>];

and: col($(ii))[3] = smin; //not crucial

Hope it will help. Unfortunately, I have no time to run script right now to test. Best,

Nikolay
Go to Top of Page

bedibra

France
35 Posts

Posted - 08/29/2017 :  04:57:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have tried you suggestions, but it did not work !

quote:
Originally posted by nick_n

Obviously, it should be :

range r1 = [profiledata]filtred!wcol($(ii));
sum(r1);
simax=sum.imax;
range r2 = [profiledata]filtred!wcol($(ii))[1:$(simax)];
range r3 = [profiledata]filtred!wcol($(ii))[$(simax):<end>];

and: col($(ii))[3] = smin; //not crucial

Hope it will help. Unfortunately, I have no time to run script right now to test. Best,

Nikolay

Go to Top of Page

bedibra

France
35 Posts

Posted - 08/30/2017 :  05:15:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Finally I found the problem.
All I had to do is to add this two lines (underlined) to the script.


// script de reduce rows
wreducerows irng:=[profiledata]vlineprofile!2 method:=mask orng:=[profiledata]"split data"!1;
// script de split data
range split2=[profiledata]"split data"!2:end;
del split2;
colsplit irng:=[profiledata]"split data"!1 method:=seq nrows:=200 rd:=[profiledata]"split data"!2;
// script de filtred
range filtred=[profiledata]filtred!2:end;
del filtred;
range split=[profiledata]"split data"!;
for(ii=2; ii<=split.ncols; ii++)
{
range source = [profiledata]"split data"!col($(ii));
range target = [profiledata]filtred!col($(ii));
fft_filters (source) oy:= (target);
}
// script de analysis (exclude the last transient)
range analysis=[profiledata]analysis!2:end;
del analysis;
range timems = [profiledata]filtred!1;
range coo=[profiledata]filtred!;
for(ii=2; ii<=coo.ncols-1; ii++)
{
window -a profiledata;
page.active$ = analysis;

range r1 = [profiledata]filtred!wcol($(ii));
range r2 = [profiledata]filtred!wcol($(ii))[1:$(simax)];
range r3 = [profiledata]filtred!wcol($(ii))[$(simax):<end>];
sum(r1);
simax=sum.imax;
sum(r2);
col($(ii))[1] = timems(sum.imax)-timems(sum.imin);
col($(ii))[2] = Max(r1);
sum(r3);
smin=sum.min;
col($(ii))[3] =$(smin);
nlbegin iy:=(timems,r3) func:=Exponential nltree:=ParamTree;
nlfit;
nn=ParamTree.R0;
nlend;
Col($(ii))[4]=-1/nn;
}
//get the mean
range results=[profiledata]results!2;
del results;
rowstats irng:=[profiledata]analysis!2:end mean:=[profiledata]results!2 sd:=<none>;


Edited by - bedibra on 08/30/2017 05:15:58 AM
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 09/01/2017 :  05:22:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Let me back to my previous message.
In your code the variable "simax" is global (undefined) and you get new value for that after range1-3 definition:

range r1 = [profiledata]filtred!wcol($(ii));
range r2 = [profiledata]filtred!wcol($(ii))[1:$(simax)];
range r3 = [profiledata]filtred!wcol($(ii))[$(simax):<end>];
sum(r1);
simax=sum.imax;

In this case the value of simax will be "last used" from previous running of script.
Thus, first loop of your script could produce wrong result. To avoid that try to use:

range r1 = [profiledata]filtred!wcol($(ii));
sum(r1);
int simax=sum.imax;
range r2 = [profiledata]filtred!wcol($(ii))[1:$(simax)];
range r3 = [profiledata]filtred!wcol($(ii))[$(simax):<end>];

Best,


Nikolay
Go to Top of Page

bedibra

France
35 Posts

Posted - 09/01/2017 :  05:45:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
indeed, I did not see that.
can you tell me what is the difference between int simax and simax ?
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 09/01/2017 :  05:52:38 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

"Scope of Variables

The way a variable is declared determines its scope. Variables created without declaration (only allowed for types double, string, and dataset) become Project variables and are saved with the Origin Project file. Declared variables become Session or Local variables. "

See more: http://www.originlab.com/doc/LabTalk/guide/Data-Types-and-vars#Scope_of_Variables

BR,

Nikolay
Go to Top of Page

bedibra

France
35 Posts

Posted - 09/01/2017 :  07:36:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
dear nick
can you please take a look at this post and let me know what do you think ?
http://www.originlab.com/forum/topic.asp?TOPIC_ID=34570
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 09/01/2017 :  07:54:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I have no ready to use solution for that yet.
Actually, sometimes I use ImageJ to get profiles.
BR,

Nikolay
Go to Top of Page

bedibra

France
35 Posts

Posted - 09/01/2017 :  08:06:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK thanks
quote:
Originally posted by nick_n

Hi,

I have no ready to use solution for that yet.
Actually, sometimes I use ImageJ to get profiles.
BR,

Nikolay

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000