Question concerning the Igor Text Wave loader

Dear users,

I am a physicist and I have some problems with the import of Igor Text Wave. In the past I used a program that exported my data in .pxt. In these files I had useful information in the note section. Now my new software exports my data in .itx files but I have no more information after loading. In the header of the .itx files this information is present but it is commented (see attachment). Is it possible to read this information and reposition it in note?

thank you in advance

Th.

IGOR
X //Created Date (UTC): 2021-Mar-05 13:31:06.073336
X //IGOR Text File Exporter Version: 0.3
X //Acquisition Parameters:
X //Scan Mode         = Fixed Analyzer Transmission
X //User Comment      = Toms

 

In order for this information to be added to a wave note, the comments would need to be changed to Note commands, for example:

IGOR
X Note/K wave0, "Created Date (UTC): 2021-Mar-05 13:31:06.073336"
X Note wave0, "IGOR Text File Exporter Version: 0.3"

So whatever software is writing the .itx file would need to be changed.

If the note is not associated with a particular wave, it might be stored in a global string variable, like this:

IGOR
X String/G gFileNote = "Created Date (UTC): 2021-Mar-05 13:31:06.073336"
X gFileNote += "\rIGOR Text File Exporter Version: 0.3"

 

 

 

 

Damn my fears are confirmed. I don't have access to the software that exports my data... The developers are not necessarily the users -^-^-

Anyway, thanks for the reactivity 

Hmm... I don't know how this looks in the file, but if the information is there it should be possible to load it in some way, e.g., by FReadLine or FBinRead. Could you post an example file and a description what you want to do with the info (e.g., assign it to a wave etc.)?

The information is just a note to remember the parameters of the experiment. So I want to store them in the note section of the 3D wave generated by the software. I attach the complete structure of my .itx files.

 

IGOR
X //Created Date (UTC): 2020-Sep-11 10:33:42.962290
X //IGOR Text File Exporter Version: 0.3
X //Created by: SpecsLab Prodigy, Version 4.53.2-r80814
X //Acquisition Parameters:
X //Scan Mode         = Fixed Analyzer Transmission
X //User Comment      = Toms
X //Analysis Mode     = UPS
X //Lens Mode         = WideAngleMode
X //Lens Voltage      = 400V
X //Analyzer Slits    = 2:0.8x30c\B:open
X //Number of Scans   = 1
X //Number of Samples = 351
X //Scan Step         = 0.01
X //DwellTime         = 0.1
X //Excitation Energy = 21.2182
X //Kinetic Energy    = 17.9
X //Binding Energy    = 3.3182
X //Pass Energy       = 15
X //Retarding Ratio   = 0.897453
X //Bias Voltage      = 0
X //Detector Voltage  = 1500
X //WorkFunction      = 4.4382
WAVES/O/S/N=(1040,351,11) '1_Spectrum'
BEGIN
2533.42 2519.3 2490.56 2527.84 2489.68 2408.12 2410.97 2410.63 ..........
END
X SetScale/I x, -14, 14, "Non-Energy Channel [deg]", '1_Spectrum'
X SetScale/I y, 17.9, 21.4, "Kinetic Energy [eV]", '1_Spectrum'
X SetScale/I z, -4, 6, "polar [deg]", '1_Spectrum'
X SetScale/I d, -4, 6, "cps (Intensity)", '1_Spectrum'

 

Here is a small script which should load this information. The header is saved into all loaded wave notes. Invoke LoadITXwithHeader() directly to load the file manually. There is an additional BeforeFileOpenHook() function in there which covers loading via drag-and-drop and double-clicking the file (I find it more convenient this way). Let me know if you encounter any problems.

static Function BeforeFileOpenHook(Variable refNum, String fileNameStr, String pathNameStr, String fileTypeStr, String fileCreatorStr, Variable fileKind)
    if (StringMatch(fileNameStr,"*.itx"))
        PathInfo $pathNameStr
        LoadITXwithHeader(S_path+fileNameStr)
        return 1
    endif
    return 0
End

// -------------------

Function LoadITXwithHeader(String filePath) // loads itx with header info
    int i, refNum = 0
    Open /R refNum as filePath  // Open the file for reading
    if (refNum == 0)
        return -1   // Error opening file
    endif
   
    String currLine = "", comment = ""
    FReadLine refNum, currLine  // "IGOR" line
    do
        FReadLine refNum, currLine  // keep reading lines
        if (!StringMatch(currLine,"X //*"))
            break
        endif
        comment += ReplaceString("X //",currLine,"")
    while(1)
    Close refNum
   
    LoadWave/O/T/Q filePath     // load the actual waves
    String wList = S_waveNames
   
    for (i=0; i<ItemsInList(wList); i++)    // assign notes to all loaded waves
        Wave w = $StringFromList(i, wList)
        Note w, comment
    endfor 
    return 0
End

 

itx loader_0.ipf (1.05 KB)

Nice.

I think you're missing a close statement, should be just before LoadWave. Or maybe LoadWave forces a close? Even so it would nice to close the file.

Tony, good catch. I have added the Close statement into above post. I don't know if the file is forcibly closed by the LoadWave command or if the open file stack gets just full at some point, but we'd better not test our luck here. :)

If you want to add a menu item:

menu "Load Waves"
    "Load Special ITX Files...", /Q, SpecialITXloader()
end

function SpecialITXloader()
    int i
    open /D/R/MULT=1/F="ITX Files (*.itx):.itx;"/M="Looking for Special ITX files..." refnum
    wave /T w_selection = ListToTextWave(S_fileName, "\r")
    for (i=0;i<numpnts(w_selection);i+=1)
        // use chozo's file loader
        LoadITXwithHeader(w_selection[i])
    endfor
    return 1
end

 

Thanks, I am trying to incorporate this code into my procedure.