November 7, 2016 at 5:48 pm #7236
Sorry to disturb again. After all my problems solved I’m getting good results with CellSpace but I was wondering If could be possible to export the data map for each wave (or element) in XYZ format, I mean, XY (coordinates) and Z (concentration).
Thanks a lot
November 7, 2016 at 11:13 pm #7241
Dr Bence PaulKeymaster
There is no built-in way to export x,y,z data, but below is a bit of code that you can copy and paste into a procedure window within iolite, after you have created your CellSpace image. It will create a text wave of x,y,z data for your currently displayed image. Depending on the size of your image, it may take a couple of minutes to process.
Once it is finished, you can save the result using the Data menu -> Save Waves.
Function ExtractXYZvalues() DFREF dfSav = GetDataFolderDFR() SetDataFolder root:Packages:iolite:CellSpaceImages Wave CellSpace_Sample If(!WaveExists(CellSpace_Sample)) DoAlert 0, "Could not find the CellSpace_Sample image. Process aborted." Abort EndIf Variable NoOfRows = dimsize(CellSpace_Sample, 0) Variable NoOfCols = dimsize(CellSpace_Sample, 1) Make /O /T /N=(NoOfRows * NoOfCols + 1) ImageXYZ ImageXYZ = "x,y,z" Variable RowCounter, ColCounter For(RowCounter = 0; RowCounter < NoOfRows; RowCounter += 1) Print "Processing Row " + num2str(RowCounter + 1) For(ColCounter = 0;ColCounter < NoOfCols;ColCounter += 1) ImageXYZ[RowCounter * NoOfCols + ColCounter + 1] = num2str(RowCounter) + "," + num2str(ColCounter) + "," + num2str(CellSpace_Sample[RowCounter][ColCounter]) EndFor EndFor Edit ImageXYZ SetDataFolder dfSav EndNovember 8, 2016 at 8:20 pm #7256
Many, many thanks, Vence
It’s working great, I can export now the data to make further treatment and combine with other images…
Thanks a lot for your help
ManuelNovember 8, 2016 at 8:21 pm #7257
Sorry…my automatic corrector didn’t understand “Bence” and he wrote “Vence” instead… sorry…December 22, 2016 at 9:42 pm #7692
I am trying to do exactly this, create an XY (coordinates) and Z (concentration) datafile of a range of trace elements that can be exported from the CellSpace image. However, when I copy the above code into the procedure window and execute the code, I receive a CommandError: “expected wave name, variable name, or operation.”
Any advice on what to do? Do i first need to save the CellSpaceImage that is displayed on the screen in some way?
Thanks a lot!
May 10, 2018 at 4:48 am #12142
- This reply was modified 2 years, 8 months ago by Freya George.
Thanks for this very useful bit of code. Is it possible to do a similar XYZ data export if you have created an Image from Selections? If so, could you post the code please?
IanMay 29, 2018 at 12:31 pm #12337
Thank you for that code, I just found it today (Thanks Tephy!), and have successfully compiled it and have made an attempt at exporting the data. However, I strongly suspect there is a better approach than what I am doing in my attempt to get the CPS data and its XY coordinates out of iolite and into iogas. My work flow so far:
* used the “save wave” option to create a text file with the default name of “StageX_Itnerped++.txt” containing quite a variety of different bits of information on X-Y values
* use the “save wave” option to create a text file with the default name of “TotalBeam++.txt” containing the raw CPS data
* combine information from both files into a single file (using the row and column labels that I had chosen to “write” in the above step to confirm that they line up with one another
* Add 1 new columns each next to the X and Y values and add formulas to say “true” if the adjacent value is the same as the above cell, and “false if it is different.
* Add three new columns and name them (e.g. “name”, the second “laser spot #”, and “jump here”)
* Starting at the top of the file, for the first set of data for which both the X and Y text results are “true” (e.g. the stage was not moving) enter the name of the first laser spot (e.g. “blank”) in the name column, and a “1” in the laser spot column . Page down till you reach the first row where those test resuts are “false (e.g. the stage was moving) and enter “move” in both of those columns. Use the cntrl-arrow to jump back to where you had entered the name, and use the automatic fill down option to copy the name and number down to the start of the move. Jump back to the bottom, enter a 1 in that third column.
* Repeat this procedure for all of the other laser spots and moving between them (use that third column to jump to the last one to double check that you are about to enter the correct number).
Note that when you get to the map you will be looking for the next place where X is false but Y is true, as the stage is moving from left to right, but not in the Y direction. (if you had run standards as lines as well then, of course, this would have been the case from the beginning).
Doing this by hand like this is kinds of tedious, but, in theory, when I am done, I will be able to open the data in iogas, where I can look at one type of data at a time and used differences in range of values for the various channels to be able to tell which phase is which and assign a colour/size/shape attributes for the different phases till I am confidant that I have them all correct.
It is my hope that once I have done that I will be able use the automatic selection from beam intensity to assign everything to their phases based on the upper and lower limits revealed by iogas. If that works, it is my hope that I could then apply the X_Trace_Elements_IS to the various phases, and then make a new cellspace map, with units in ppm or wt% (as appropriate).
While I would, of course, welcome advice on any stage in this plan, I am specifically asking for easier ways to get the X-Y data and the CPS data out of iolite and to assign the names and laser numbers. Did I miss some obvious choice in the export window? Would it be possible to write a script to do the assignment of names and numbers automatically, instead of needing to to them by hand?
Thank you for any thought you can shareJune 1, 2018 at 4:29 am #12360
Dr Tephy Marillo-SialerKeymaster
To run the code, copy and paste it into the Procedure window which you can open using the top menu bar: Windows > Procedure Windows > Procedure Window. Then copy and paste the function name (e.g. ExtractXYZvalues()) into the bottom line of the Command Window (Windows>Command Window) and hit the return key.
For CellSpace, the code will create a wave called ImageXYZ which corresponds to the currently plotted image in the CellSpace window. The code will append this wave to a Table which you can save by going to File > Save Table copy… after selecting the required file format (csv, txt, etc). You can also save the new wave using the Save Waves option (Data > Save Waves) and selecting ImageXYZ from the wave list.
If you want to export a different CellSpace map (channel) you have to close the table, then plot the other channel from the CellSpace Window and re-run the code.
Ian, below is the code to export XYZ data from Image from Selections maps. In this case, the code will generate a XYZImage wave for each existing map and will append each to separate table.
Function ExtractXYZvaluesImgSel() DFREF dfSav = GetDataFolderDFR() SetDataFolder root:Packages:iolite:images String ListOfMapWaves = WaveList("*Map", ";", "") Variable NoOfMaps = ItemsInList(ListOfMapWaves) Variable MapCounter For(MapCounter = 0; MapCounter < NoOfMaps; MapCounter += 1) String NameOfMap = StringFromList(MapCounter, ListOfMapWaves) Wave ThisMap = $NameOfMap If(!WaveExists(ThisMap)) DoAlert 0, "Could not find the map image. Process aborted." Abort EndIf Variable NoOfRows = dimsize(ThisMap, 0) Variable NoOfCols = dimsize(ThisMap, 1) String ThisXYZImage = "ImageXYZ_" + NameOfMap Make /O /T /N=(NoOfRows * NoOfCols + 1) ImageXYZ Rename ImageXYZ, $ThisXYZImage Wave/T XYZImage = $ThisXYZImage XYZImage = "x,y,z" Variable RowCounter, ColCounter For(RowCounter = 0; RowCounter < NoOfRows; RowCounter += 1) //Print "Processing Row " + num2str(RowCounter + 1) For(ColCounter = 0;ColCounter < NoOfCols;ColCounter += 1) XYZImage[RowCounter * NoOfCols + ColCounter + 1] = num2str(RowCounter) + "," + num2str(ColCounter) + "," + num2str(ThisMap[RowCounter][ColCounter]) EndFor EndFor Edit XYZImage EndFor SetDataFolder dfSav EndMarch 2, 2019 at 4:16 pm #13778
Hi, Tephy and Bence,
Some time ago I opened this topic for exporting the cellspace data to an XYZ file. On this time, with your instructions It was successful, but now, I’m just working on mapping again and I cannot reproduce this. I create a cellspace image by overlapping the results over a .png image with coordinates, everything it’s ok, but when I export the data, if the reference image is bigger than 10 Mb the system takes hours and hours creating the output XYZ table, if I use no image, just coordinates, the output xyz table has no coordinates, it starts with x=1 and y=1 and also in reverse mode.If I use an smaller image (Img01_Mapped.png + Img01.coord) I get again the same xyzzy table without the coordinates. When the table appears in screen after applying ExtractXYZvalues() I save this table, I don’t know if I have to save waves instead this table, and which wave to export… I’m lost again..
Thanks a lot
ManuelMay 21, 2019 at 7:20 pm #13989
In the case of U-Pb data is it possible to get the standard error and error correlation of each point?
You must be logged in to reply to this topic.