Probe Software Users Forum

Software => CalcImage => Topic started by: Gareth D Hatton on February 21, 2014, 04:19:19 AM

Title: Batch Processing
Post by: Gareth D Hatton on February 21, 2014, 04:19:19 AM
I have a question for the community:

Do you think we need batch processing on CalcImage?

What I mean by this is I have just done 28 samples looking for the same elements each time with the same conditions  Currently each one has to be processed as a single project.

This takes a while.

Does anyone else do this type of analysis and would this feature be useful?
Title: Re: Batch Processing
Post by: John Donovan on February 22, 2014, 02:41:51 PM
Quote from: Gareth D Hatton on February 21, 2014, 04:19:19 AM
Do you think we need batch processing on CalcImage?

Hi Gareth,
You make a valid point.

There are a number of ways this could be implemented. For example I could implement the program to process a command line argument which contains various information, for example the CIP project name.

But because the CIP project file contains the calculation flags, e.g., atomic, oxide, formula, etc, those need to be specified first before the quant mapping calculation starts.

So you'd have to create the projects first (but don't run the quant calculation yet) and then create a batch file like this:

call CalcImage "<projectname1>.CIP"
call CalcImage "<projectname2>.CIP"
call CalcImage "<projectname3>.CIP"

etc.

This way you could have all the quant calculations automated,  though you'd still have to create all the projects with their appropriate calculation flags specified first.

Then for the quant, you could process all the project without user intervention (I would have to set a flag to skip the user confirmation after each project is complete).

Would that help?
john
Title: Re: Batch Processing
Post by: Gareth D Hatton on February 25, 2014, 12:25:55 AM
Hi John,
I think that it could be a useful if it is easy to implement, I can always just plug myself in and churn through.

Since the flags are all the same in all of the projects I could in theory copy and paste into a new file using Vim or some other and save the file under the next file name.  However I have noticed that there are other long numbers to contend with (such as 41690.6915856482).  What are these and is there any way to find them?
Title: Re: Batch Processing
Post by: Probeman on February 25, 2014, 01:10:44 PM
Quote from: Gareth D Hatton on February 25, 2014, 12:25:55 AM
Since the flags are all the same in all of the projects I could in theory copy and paste into a new file using Vim or some other and save the file under the next file name.  However I have noticed that there are other long numbers to contend with (such as 41690.6915856482).  What are these and is there any way to find them?
Good question and sorry the documentation isn't quite up to date on this topic!

Here is a pictorial description of the CIP file format. The lastest CalcImage help file also contains more information on page 12 of the CalcImage.pdf file but I will put that in a dropbox for you because it is too big to post as an attachment.

(https://smf.probesoftware.com/oldpics/i62.tinypic.com/2ish45l.jpg)

So, would you like me to add the ability to process each CIP file from a batch file without user intervention?
Title: Re: Batch Processing
Post by: John Donovan on February 13, 2018, 08:28:12 AM
Some people have asked me what units the time values in the CalcImage CIP file are in.

These date/time values are the same as Microsoft Excel uses, which are in the number of days elapsed since 1899. Where day 1 (one) of the Excel dates is Jan 1, 1900.  The values to the right of the decimal point are for time as a fractional day.

So recent date/time values are on the order of 40000 or so.  Don't blame me, blame Bill Gates!    :)

Title: Re: Batch Processing
Post by: Ben Buse on February 19, 2018, 03:44:11 AM
Quote from: John Donovan on February 22, 2014, 02:41:51 PM

call CalcImage "<projectname1>.CIP"
call CalcImage "<projectname2>.CIP"
call CalcImage "<projectname3>.CIP"

etc.


Hi John,

I guess the above would help. But more useful would be when the mdb & configuration using for quantifying the maps has not changed. Apply the mdb & configuration to multiple sets of maps. But I guess this would be pretty difficult?

Ben
Title: Re: Batch Processing
Post by: John Donovan on February 19, 2018, 08:10:13 AM
Hi Ben,
I'm not exactly sure what you have in mind here.

What is the goal you are trying to accomplish?   Can you provide an example of what you want to do?
john
Title: Re: Batch Processing
Post by: Ben Buse on February 19, 2018, 08:19:05 AM
I guess this is similar to what Gareth is doing (is that right Gareth?), but if you were to batch - were it would be useful is in the following situation

Trace Si and Zn in many steel samples.

MDB - calibrate for trace Si and Zn, set up blank correction for Si and Zn as unknown sample, set up MAN backgrounds.

PI - run a series of Si,Zn maps on many samples.

Tell calcimage to process collectively the many samples using the MDB and unknown sample setup (rather than setting up individual projects).

Ben
Title: Re: Batch Processing
Post by: John Donovan on February 19, 2018, 11:32:53 AM
Quote from: Ben Buse on February 19, 2018, 08:19:05 AM
I guess this is similar to what Gareth is doing (is that right Gareth?), but if you were to batch - were it would be useful is in the following situation

Trace Si and Zn in many steel samples.

MDB - calibrate for trace Si and Zn, set up blank correction for Si and Zn as unknown sample, set up MAN backgrounds.

PI - run a series of Si,Zn maps on many samples.

Tell calcimage to process collectively the many samples using the MDB and unknown sample setup (rather than setting up individual projects).

Hi Ben,
One difficulty is that each CalcImage project might consist of more than one spectrometer pass (if more than 5 elements are acquired).  So how would the "batch processor" know which sets of maps go together?

Maybe the best solution is to modify CalcImage to take a .CIP file as a command line argument and process it automatically as I originally described above with Gareth.

Also now that we can output all data types automatically from CalcImage, one could quant each project and then output them all by calling CalcImage with each project file as originally described:

Quotecall CalcImage "<projectname1>.CIP"
call CalcImage "<projectname2>.CIP"
call CalcImage "<projectname3>.CIP"
etc.

The only remaining task would be that the user would have to generate a script that creates a CalcImage project file based on the MDB, sample setup and maps specified by the user.  For a clever guy like you that should be easy!   :)  The CIP project file format is documented above and in the CalcImage help file.

How does that sound?
Title: Re: Batch Processing
Post by: Gareth D Hatton on February 21, 2018, 01:27:16 AM
Quote from: Ben Buse on February 19, 2018, 08:19:05 AM
I guess this is similar to what Gareth is doing (is that right Gareth?), but if you were to batch - were it would be useful is in the following situation

Trace Si and Zn in many steel samples.

MDB - calibrate for trace Si and Zn, set up blank correction for Si and Zn as unknown sample, set up MAN backgrounds.

PI - run a series of Si,Zn maps on many samples.

Tell calcimage to process collectively the many samples using the MDB and unknown sample setup (rather than setting up individual projects).


I am certainly doing multiple analyses using the same set up on many samples (for instance at the moment I am setting up to do one run of elements on 18 samples which all are pretty much the same).  I currently only process them by opening multiple instances of Calcimage.  I am not sure there is a viable workaround...  I had a quick play with call but could only get it to launch CalcImage if I used the entire path and also then it would not automatically open the CIP file so I left it there.
Title: Re: Batch Processing
Post by: John Donovan on February 21, 2018, 06:14:49 AM
Hi Gareth,
Having CalcImage perform processing of a CIP file from the command line is a proposal, it's not implemented yet!  Actually it is implemented as of last night but I haven't released it!

First I need to update the CalcImage Help file and I want to re-arrange some of the menus, but I will have something interesting later today or tomorrow for you to try.  But yes, you will need to run your batch file from the PFE/CI app folder or call CalcImage with the full application path as you describe. Probably better to specify the full app path in your batch file as then you can keep the batch files in the same folder as your CIP projects...

One interesting application for this batch processing method in CalcImage is that if one wanted to tweak one calculation option, since they are generally stored in the MDB file, you will be able to make the change once, and then reprocess all the maps with a single batch call.
Title: Re: Batch Processing
Post by: John Donovan on February 24, 2018, 09:22:06 AM
Hi Gareth and Ben,
We think we have something that will do what you want for batch processing of quant map projects in CalcImage.

The first thing we did was to modify CalcImage to accept a command line argument. This command line argument must be a CalcImage .CIP project file with the full path. Here is an example of a batch file that will launch CalcImage and automatically load the specified CIP project:

(https://smf.probesoftware.com/gallery/1_24_02_18_9_12_23.png)

There are two parts to each line, first a string containing the full path to the CalcImage app in double quotes. This first part will always stay the same. The second part is the full path to the CalcImage project file to be automatically reprocessed, also in double quotes.

We also modified the code for creating a new project. That is when you create a new CalcImage project using the CalcImage project wizard, the software will now automatically append that project to a file (CIP_Batch.bat) in the user's current project folder with the new project name, similar to that shown in the example above.  Of course one is also welcome to create their own batch files to load their CalcImage projects automatically.

Once each CalcImage project is loaded from the command line, CalcImage will automatically load the raw intensity files, re-calculate the quant maps, and automatically output all quant maps. All based on the existing element to map assignments and data output types selected by the user.

The batch file will process each project file one at  time.  Of course one could run multiple batch files simultaneously.  Please let me know if this is useful for your batch processing needs.
Title: Re: Batch Processing
Post by: John Donovan on February 24, 2018, 09:29:09 AM
I should mention again that this command line argument batch processing in CalcImage will not work unless the user has already assigned the maps to the quant elements using the Specify Quantitative Parameters menu.

Of course there is nothing to prevent anyone from creating their own .CIP project files with the x-ray maps already assigned to the elements and the data types specified from a script of their own devising.  Towards that goal we have documented the CIP file format in detail in the latest CalcImage help file as seen here:

(https://smf.probesoftware.com/gallery/1_24_02_18_9_26_49.png)

To further assist your own script development for batch processing I have posted here the actual code used to write the CalcImage project file:

' Project file does not contain full path (uses current CIP folder)
Open CalcImageProjectFile$ For Output As #CalcImageProjectFileNumber%

Print #CalcImageProjectFileNumber%, CalcImageProjectVersion%, VbDquote$ & CalcImageProjectTitle$ & VbDquote$
Print #CalcImageProjectFileNumber%, VbDquote$ & CalcImageSampleNameTitle$ & VbDquote$
Print #CalcImageProjectFileNumber%, VbDquote$ & MiscGetFileNameOnly$(ProbeDataFile$) & VbDquote$
Print #CalcImageProjectFileNumber%, CalcImageProbeDataSample%, CalcImageNumberofImageFiles%, CalcImageCalculateTotalsImageFlag%, CalcImageCalculateStoichiometricOxygenImageFlag%, CalcImageCalculateExcessOxygenImageFlag%, CalcImageCalculateNetIntensitiesFlag%, CalcImageCalculateBgdIntensitiesFlag%, CalcImageCalculateKratioIntensitiesFlag%, CalcImageCalculateQuantPercentsFlag%, CalcImageCalculateAtomicPercentsFlag%, CalcImageCalculateOxidePercentsFlag%, CalcImageCalculateFormulaBasisFlag%, CalcImageCalculateElementByDiffImageFlag%, CalcImageCalculateDetectionLimitsFlag%, CalcImageCalculateAnalyticalSensitivityFlag%, CalcImageCalculateLogWeightPercentsFlag%, CalcImageCalculateDetectionLimitsBlankingFlag%, CalcImageCalculateAnalyticalSensitivityBlankingFlag%, Int(0)

' Write on and off peak image files
For i% = 1 To CalcImageNumberofImageFiles%
Print #CalcImageProjectFileNumber%, CalcImageImageTypes%(i%), CalcImageElementRows%(i%), Format$(CalcImageCountTimes!(i%), f83$), CalcImageBeamCurrents!(i%), CalcImageBeamCurrents2!(i%), CalcImageTimeOfAcqs#(i%), CalcImageTimeOfAcqs2#(i%), VbDquote$ & MiscGetFileNameOnly$(CalcImageImageFiles$(i%)) & VbDquote$
Next i%

' Now write CPQ files and parameters
Call CalcImageCPQReadWriteProjectFile(mode%, CalcImageProjectFileNumber%)
If ierror Then Exit Sub

' Now write misc parameters
Print #CalcImageProjectFileNumber%, CalcImageTitleAppendDataFlag%, CalcImageSurferOutputTemplateFlag%, CalcImageSurferSliceTemplateFlag%, CalcImageSurferPolygonTemplateFlag%, CalcImageSurferStripTemplateFlag%, itemp5%, itemp6%

' Now write EDS spectrum image flag and filename
Print #CalcImageProjectFileNumber%, IntegrateEDSSpectrumImagingFlag, VbDquote$ & IntegrateEDSSpectrumImagingFilename$ & VbDquote$

' Now write scan type and stage type
Print #CalcImageProjectFileNumber%, CalcImageScanTypeFlag%, CalcImageStageTypeFlag%

' Now write analog signal image output flags and names
Print #CalcImageProjectFileNumber%, CalcImageAnalogSignalFlags(1), VbDquote$ & CalcImageAnalogSignalLabels(1) & VbDquote, CalcImageAnalogSignalFlags(2), VbDquote$ & CalcImageAnalogSignalLabels(2) & VbDquote, CalcImageAnalogSignalFlags(3), VbDquote$ & CalcImageAnalogSignalLabels(3) & VbDquote

' Now write analog signal file names
Print #CalcImageProjectFileNumber%, VbDquote$ & MiscGetFileNameOnly$(AnalogFilenames$(1)) & VbDquote$, VbDquote$ & MiscGetFileNameOnly$(AnalogFilenames$(2)) & VbDquote$, VbDquote$ & MiscGetFileNameOnly$(AnalogFilenames$(3)) & VbDquote$

' Now write number of TDI files and number of TDI intervals
Print #CalcImageProjectFileNumber%, CalcImageNumberOfTDIImageFiles%, CalcImageNumberOfTDIImageIntervals%

' Write TDI image files
For i% = 1 To CalcImageNumberOfTDIImageFiles%
Print #CalcImageProjectFileNumber%, CalcImageTDIImageIntervals%(i%), CalcImageTDIElementRows%(i%), Format$(CalcImageTDICountTimes!(i%), f83$), CalcImageTDIBeamCurrents!(i%), CalcImageTDIBeamCurrents2!(i%), CalcImageTDITimeOfAcqs#(i%), CalcImageTDITimeOfAcqs2#(i%), VbDquote & MiscGetFileNameOnly$(CalcImageTDIImageFiles$(i%)) & VbDquote
Next i%

Close #CalcImageProjectFileNumber%


This plus the explanation should make it easy to develop your own CalcImage batch scripts.
Title: Re: Batch Processing
Post by: John Donovan on February 24, 2018, 09:39:56 AM
I should also point out that one very cool advantage to this CIP_Batch.bat file is that once you manually (or through your own scripting code) create a .CIP project file (and the project is appended to the CIP_Batch.bat file), one can easily re-calculate and output all of one's projects by simply re-running the CIP_Batch.bat file from their user data folder.

For example, lets say that one decides to utilize a different matrix correction, or change the background model, or re-assign a standard or add an interference correction or change the element or formula by difference... since all these parameters are stored in the MDB file (which contains the element setup and standard intensities and is therefore usually the same for a related set of quant x-ray maps), one just makes the desired change to the element setup in PFE or CalcImage and then one simply double-clicks the CIP_Batch.bat file and all the CalcImage projects in the batch file are automatically loaded, re-calculated and output again.

I suspect that this is something that everyone will find useful even if you don't want to get into writing your own .CIP files from a script.   8)

It's difficult to show with still images how fun it is to watch CalcImage load, reprocess and output many projects, all automatically without user intervention, but here is an image of CalcImage running from a batch file (see command prompt window in upper left), with the quant calculation being re-run:

(https://smf.probesoftware.com/gallery/1_24_02_18_9_12_47.png)

Next is an image of the quant map reprocessing completed and loaded:

(https://smf.probesoftware.com/gallery/1_24_02_18_9_13_06.png)

and finally an image of all the map data types (elemental, atomic percent, oxide, k-ratios, detection limits, etc., etc.) being automatically output from Surfer:

(https://smf.probesoftware.com/gallery/1_24_02_18_9_13_27.png)

This new CalcImage batch processing capability is now available with PFE v. 12.1.9 which one can obtain from the PFE Help menu.
Title: Re: Batch Processing
Post by: JonF on October 19, 2018, 10:14:07 AM
I was just about to add a batch processing feature to the CalcImage wish list thread... guess I'm behind the curve by 8 months!

Nice, thanks John!
Title: Re: Batch Processing
Post by: John Donovan on October 21, 2018, 12:46:23 PM
Quote from: JonF on October 19, 2018, 10:14:07 AM
I was just about to add a batch processing feature to the CalcImage wish list thread... guess I'm behind the curve by 8 months!

Nice, thanks John!

Hi Jon,
No worries.  Glad you were able to discover it!  I guess that's one of the many nice things about this user forum is that it is searchable.

Since you are a relatively new customer you should not blame yourself, there's a lot of cool features in the software for one to discover, as people have been using our Probe software in one form or another and making wonderful suggestions for over 20 years.  I myself even occasionally discover new and useful features that I had completely forgotten about!  :-[

It's worth checking the About menu in one of our apps to see who some of these people are.  They deserve a lot of credit for making this project possible at all. 
Title: CIP_Batch.bat
Post by: Gseward on June 12, 2025, 04:15:32 PM
Is there a way to modify the behaviour when a CIP_batch.bat file is executed?

e.g. maybe I have Surfer installed on my PC, but on this occassion I don't want to output all of the calculations to Surfer format. 

or maybe I want to send the calculations to Classify Image Exporter.exe

Cheers,

Gareth
Title: Re: Batch Processing
Post by: John Donovan on June 13, 2025, 08:18:19 AM
Quote from: Gseward on June 12, 2025, 04:15:32 PMIs there a way to modify the behaviour when a CIP_batch.bat file is executed?

Let's review what the CIP_Batch.bat files does when processed by CalcImage. Here is the command line code:

Sub CalcImageCommandLine(tForm As Form)
' Check for CIP file on command line

ierror = False
On Error GoTo CalcImageCommandLineError

Dim tfilename As String
Dim tSurferPageSecondsDelay As Integer

' Check for command line string
tfilename$ = Command$()
If tfilename$ = vbNullString Then Exit Sub

' Confirm command line argument
If DebugMode Then Call IOWriteLog(vbCrLf & "Raw Command line argument (CIP file): " & tfilename$)

' Remove double quotes from filename (put there by Command function) which causes Dir$ function to fail
If Left$(tfilename$, 1) = VbDquote And Right$(tfilename$, 1) = VbDquote Then    ' no double quotes if drag and drop
tfilename$ = Mid$(tfilename$, 2)
tfilename$ = Left$(tfilename$, Len(tfilename$) - 1)
End If

' Check for valid file
If Dir$(tfilename$) = vbNullString Then GoTo CalcImageCommandLineNotFound
If UCase$(MiscGetFileNameExtensionOnly$(tfilename$)) <> ".CIP" Then GoTo CalcImageCommandLineBadExtension

' Set some globals
UserDataDirectory$ = MiscGetPathOnly2$(tfilename$)
UserDataDirectory2 = UserDataDirectory$     ' to synchronize quant and classify

' Get the standard names, numbers and descriptions from standard database
Call StandardGetMDBIndex
If ierror Then Exit Sub

' Update globals
CalcImageProjectFile$ = tfilename$
CalcImageProjectFileSaved = True
CalcImageSampleNameTitle$ = MiscGetFileNameOnly$(MiscGetFileNameNoExtension$(CalcImageProjectFile$))

' Open passed filename as old file
Call CalcImageOpenOldProjectFile(Int(1), Int(0))
If ierror Then End

' Process maps
CalcImageQuantFlag = True
Call CalcImageUpdateForm
Call CalcImageStartAnalysis(Int(2), FormCALCIMAGE)
CalcImageQuantFlag = False
Call CalcImageUpdateForm
If ierror Then Exit Sub

' Output maps
tSurferPageSecondsDelay% = SurferPageSecondsDelay%
SurferPageSecondsDelay% = 1         ' set to 1 sec for all output
Call CalcImageCreateSurferOutputAll(Int(1))         ' call in silent mode
SurferPageSecondsDelay% = tSurferPageSecondsDelay%
If ierror Then Exit Sub

' Now just end for next command line batch process
End

Exit Sub

' Errors
CalcImageCommandLineError:
MsgBox Error$ & " (command line argument: " & tfilename$ & ")", vbOKOnly + vbCritical, "CalcImageCommandLine"
ierror = True
Exit Sub

CalcImageCommandLineNotFound:
msg$ = "Command line argument string, " & tfilename$ & ", is not a valid file"
MsgBox msg$, vbOKOnly + vbExclamation, "CalcImageCommandLine"
ierror = True
Exit Sub

CalcImageCommandLineBadExtension:
msg$ = "Command line argument filename, " & tfilename$ & ", does not have a CIP extension"
MsgBox msg$, vbOKOnly + vbExclamation, "CalcImageCommandLine"
ierror = True
Exit Sub

End Sub

So CalcImage looks for a command line argument which must be a CIP file. Then it loads the CIP file and starts the quantification for all data types specified.

Once the quant calculations are finished for that CIP file, it attempts to output all data types to Surfer.

Quote from: Gseward on June 12, 2025, 04:15:32 PMe.g. maybe I have Surfer installed on my PC, but on this occasion I don't want to output all of the calculations to Surfer format. 

This post here describes how we modified the code recently to skip outputting calculations to Surfer format if the Surfer app is not installed:

https://smf.probesoftware.com/index.php?topic=948.msg12304#msg12304

Does that help?

Quote from: Gseward on June 12, 2025, 04:15:32 PMor maybe I want to send the calculations to Classify Image Exporter.exe

Here is code to call the Classify Image Exporter with a classify DAT file and a palette file:

Sub CalcImageExportImagesToPNGFiles()
' Launch the Classify Image Exporter application (written by Mia Kraft)

ierror = False
On Error GoTo CalcImageExportImagesToPNGFilesError

Dim n As Integer
Dim taskID As Long
Dim astring As String, tfilename As String, pfilename As String

' Demo file
If CalcImageProjectFile$ = vbNullString Then GoTo CalcImageExportImagesToPNGFilesNoProject
tfilename$ = MiscGetFileNameNoExtension$(CalcImageProjectFile$) & "_Quant_Image_Classify.DAT"

' Get image DAT file from user
If UserDataDirectory2$ <> vbNullString Then tfilename$ = UserDataDirectory2$ & "\" & MiscGetFileNameOnly$(tfilename$)
Call IOGetFileName(Int(2), "DAT", tfilename$, FormCALCIMAGE)
If ierror Then Exit Sub

' Check if file is really a valid classify input file
Close #Temp1FileNumber%
DoEvents
Open tfilename$ For Input As #Temp1FileNumber%
Line Input #Temp1FileNumber%, astring$  ' read 1st line
Line Input #Temp1FileNumber%, astring$  ' read second line
Close #Temp1FileNumber%

n% = 0
If InStr(astring$, "NK") = 0 Then GoTo CalcImageExportImagesToPNGFilesWrongFormat
n% = 1
If InStr(astring$, "X") = 0 Then GoTo CalcImageExportImagesToPNGFilesWrongFormat
n% = 2
If InStr(astring$, "Y") = 0 Then GoTo CalcImageExportImagesToPNGFilesWrongFormat
n% = 3
If InStr(astring$, "NX") = 0 And InStr(astring$, "NS") = 0 Then GoTo CalcImageExportImagesToPNGFilesWrongFormat
n% = 4
If InStr(astring$, "NY") = 0 And InStr(astring$, "NL") = 0 Then GoTo CalcImageExportImagesToPNGFilesWrongFormat
n% = 5
If InStr(astring$, "NXY") = 0 And InStr(astring$, "ND") = 0 Then GoTo CalcImageExportImagesToPNGFilesWrongFormat

' Check that the app exists
astring$ = ProgramPath$ & "Classify Image Exporter.exe"
If DebugMode Then Call IOWriteLog("CalcImageExportImagesToPNGFiles (Dir string): " & astring$)
If Dir$(astring$) = vbNullString Then GoTo CalcImageExportImagesToPNGFilesAppNotFound

' Load the application string with selected classify DAT file
astring$ = VbDquote$ & ProgramPath$ & "Classify Image Exporter.exe" & VbDquote$ & " " & VbDquote$ & tfilename$ & VbDquote$

' Load FC file string
If ImagePaletteNumber% > 0 Then
If ImagePaletteNumber% = 1 Then pfilename$ = ApplicationCommonAppData$ & "THERMAL.FC"
If ImagePaletteNumber% = 2 Then pfilename$ = ApplicationCommonAppData$ & "RAINBOW2.FC"
If ImagePaletteNumber% = 3 Then pfilename$ = ApplicationCommonAppData$ & "BLUERED.FC"
If ImagePaletteNumber% = 4 Then pfilename$ = ApplicationCommonAppData$ & "CUSTOM.FC"
astring$ = astring$ & " " & VbDquote$ & pfilename$ & VbDquote$
End If

' Run Classify Image Exporter
If DebugMode Then Call IOWriteLog("CalcImageExportImagesToPNGFiles (Shell string): " & astring$)
taskID& = Shell(astring$, vbNormalFocus)

Exit Sub

' Errors
CalcImageExportImagesToPNGFilesError:
Screen.MousePointer = vbDefault
MsgBox Error$, vbOKOnly + vbCritical, "CalcImageExportImagesToPNGFiles"
Close #Temp1FileNumber%
ierror = True
Exit Sub

CalcImageExportImagesToPNGFilesNoProject:
msg$ = "No CalcImage Project is open"
MsgBox msg$, vbOKOnly + vbExclamation, "CalcImageExportImagesToPNGFiles"
ierror = True
Exit Sub

CalcImageExportImagesToPNGFilesWrongFormat:
msg$ = "The specified column label for column " & Format$(n%) & " is incorrect for the selected Classify DAT file." & vbCrLf & vbCrLf
msg$ = msg$ & "Please check the file format and try again. The file must be tab delimited and the column labels for the 2nd line of the data file must be NK, X, Y, NX, NY, NXY, <data1>, <data2>, etc..."
MsgBox msg$, vbOKOnly + vbExclamation, "CalcImageExportImagesToPNGFiles"
ierror = True
Exit Sub

CalcImageExportImagesToPNGFilesAppNotFound:
msg$ = "The Classify Image Exporter application was not found." & vbCrLf & vbCrLf
msg$ = msg$ & "This error should not occur. Please contact Probe Sofwtare technical support."
MsgBox msg$, vbOKOnly + vbExclamation, "CalcImageExportImagesToPNGFiles"
ierror = True
Exit Sub

End Sub

Basically it is:

"Classify Image Exporter.exe" <classify DAT filename> <palette FC filename>

The palette file in the command line is optional as it uses a gray scale palette by default. So you could call the Classify Image Exporter yourself from a command line or batch file. Then click the Export All button...

Is that helpful?
Title: Re: Batch Processing
Post by: Gseward on June 27, 2025, 06:37:04 AM
John, Thanks for taking the time to add a detailed explanation.

Perhaps I should have phrased the question as: Is there a way that the User can modify the behaviour when a CIP_batch.bat file is executed.

Perhaps the answer is simply: No!

How are you checking whether Surfer is installed? Perhaps if I knew that I could temporarily make it appear as if Surfer was not installed!

Cheers.

Gareth
Title: Re: Batch Processing
Post by: John Donovan on June 27, 2025, 07:41:00 AM
Quote from: Gseward on June 27, 2025, 06:37:04 AMPerhaps I should have phrased the question as: Is there a way that the User can modify the behaviour when a CIP_batch.bat file is executed.

The CIP_batch.bat file is not executed by CalcImage. It is executed by the user.  CalcImage only creates the CIP_batch.bat file.

Quote from: Gseward on June 27, 2025, 06:37:04 AMHow are you checking whether Surfer is installed? Perhaps if I knew that I could temporarily make it appear as if Surfer was not installed!

As stated above, CalcImage already checks if the Surfer app is not installed, and does not attempt to output data to Surfer if the app is not installed.

Here is the code we use to check if Surfer is installed:

Function BasCheckSurfer() As Boolean
' Just check if Surfer is installed or not
'  Returns false if not found, true if found

ierror = False
On Error GoTo BasCheckSurferError

Dim SurferApp As Object

' Test code
'BasCheckSurfer = False
'Exit Function

BasCheckSurfer = True

' Skip errors in case app is not installed
On Error Resume Next

' Try to create the Surfer object
Screen.MousePointer = vbHourglass
Set SurferApp = CreateObject("Surfer.Application")
Screen.MousePointer = vbDefault

' Check if object not created
If SurferApp Is Nothing Then BasCheckSurfer = False

' Resume errors
On Error GoTo BasCheckSurferError

Exit Function

' Errors
BasCheckSurferError:
Screen.MousePointer = vbDefault
MsgBox Error$, vbOKOnly + vbCritical, "BasCheckSurfer"
ierror = True
Exit Function

End Function

It just tries to create a Surfer object, and if that fails it knows that Surfer is not installed. You could write similar scripting code in any OLE container application, e.g., Excel, MatLab, etc.