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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Binary import of spectra in .spe format!

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
osohr Posted - 03/01/2007 : 08:01:29 AM
Origin Version 7.5 SR6 german:
Operating System: win 2000

Hi,

I can import the pixel intensities of my spectra with the princeton instruments (*.spe) import filter. the x-axis can be calculated with some parameters from the header. The filter writes the complete header (more than 100 lines) into the notes window.
How can i modify the OC- filter to drop the following parameters into LT
variables for x-axis calculation:
....
calib_xpolynom_coeff0 = 538.197893442706
calib_xpolynom_coeff1 = 0.102408269881526
calib_xpolynom_coeff2 = -1.53844343185115e-006
calib_xpolynom_coeff3 = 0.
calib_xpolynom_coeff4 = 0.
calib_xpolynom_coeff5 = 0.
calib_xlaser_position = 532.
....

Maybe the calculation of the x-axis could be done by OC much quicker, but basically the transfer of these specific parameters to LT would be sufficient.

There was a topic with the same problem in 2004, a solution wasn´t documented.

Thanks to all,

Oliver
5   L A T E S T    R E P L I E S    (Newest First)
osohr Posted - 03/01/2007 : 1:18:01 PM
...yessss!!

two spaces in front of every new line!
now it works!

Thanks a lot!
Mike Buess Posted - 03/01/2007 : 12:46:44 PM
I copied your original list of header lines to a notes window, ran the function and then 'list v'...

...
45 CALIB_XPOLYNOM_COEFF0 1 538.19789
46 CALIB_XPOLYNOM_COEFF1 1 0.10241
47 CALIB_XPOLYNOM_COEFF2 1 -0
48 CALIB_XPOLYNOM_COEFF3 1 0
49 CALIB_XPOLYNOM_COEFF4 1 0
50 CALIB_XPOLYNOM_COEFF5 1 0
51 CALIB_XLASER_POSITION 1 532

Possibly the lines start with # or some other character?

Mike Buess
Origin WebRing Member
osohr Posted - 03/01/2007 : 11:52:02 AM
..OK now your function runs smooth. The specific names(filename) of the notes windows were just hidden.

But how can i find the variables in LT? They should be num var with the identical names from the header !? list v in LT doesn´t show them.

Thanks again

oliver
osohr Posted - 03/01/2007 : 11:38:20 AM
Hi Mike,

I get two runtime errors when i call this function. It compiled without errors. Do i have to include anything.
For the Import of the intensities I use the Import Filter Script:
princetoninstruments.c that you can find in originlabs download area.
I think the relevant part of the script is this:

..

//--------------------------------------------------------------------------
// ImportFileToPage
//
// Imports an SPE file into the specified page.
//--------------------------------------------------------------------------
static int ImportFileToPage(Page& pgTarget, LPCSTR lpcszFile, int nFile)
{
// Open data file
file filSrc;
if( !filSrc.Open(lpcszFile, file::modeRead | file::typeBinary | file::shareDenyWrite) )
return SPE_ERR_FILE_OPEN;

// Read header
SPEHEADER spehdr;
int iRet = filSrc.Read(&spehdr, sizeof(SPEHEADER));
if( sizeof(SPEHEADER) == iRet )
{
// Read data into page
if( 1 == spehdr.ydim )
iRet = Import1DimToPage(pgTarget, filSrc, spehdr);
else
iRet = Import2DimToPage(pgTarget, filSrc, spehdr);

spe_SetPageNameAndLabel(pgTarget, spehdr, lpcszFile);

// Output header to Notes window
if( !iRet )
iRet = spe_HeaderToNotes(spehdr, lpcszFile);
}
else
iRet = SPE_ERR_READ_HEADER;

// Close data file
filSrc.Close();

return iRet;
}
...


maybe its easier to modify the original OC script, because with every import of a *.spe file into one project creates another notes window called "Notes".

Thank you for your quick response!

oliver
Mike Buess Posted - 03/01/2007 : 09:49:37 AM
Hi Oliver,

This OC function reads the named Notes window and converts all lines that start with "calib_" to LabTalk variables. I don't know what your import filter looks like now but you might be able to run this function from advanced filter options.
void get_calib_info(string strNote)
{
Note note(strNote);
string str1,str2,str = note.Text;
StringArray sa;
str.GetTokens(sa,'\n');
for(int i=0;i<sa.GetSize();i++)
{
if( sa[i].Find("calib_")==0 )
{
str1 = sa[i].GetToken(0,'=');
str2 = sa[i].GetToken(1,'=');
LT_set_var(str1,atof(str2));
}
}
}


Mike Buess
Origin WebRing Member

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000