How to define and run a simulation experiment - xcist/documentation GitHub Wiki

Running a simulation from a Python script

The simulation is defined in a Python script, which is the primary input to CatSim, whether running the executable or running from within Python. Sample scripts are included in the release; users can revise to create their own. We recommend to use filename Sim_name.py for all simulation experiments. The script should contain the following elements.

Step 1: Define simulation parameters in configuration files in the cfg folder.

Step 2: Initialize the simulation class and assign it the right configuration names. For example,

ct = xc.CatSim("Phantom_Sample", "Scanner_Samplegeneric", "Protocol_Sampleaxial")

Step 3: Choose a name for the simulation experiment, which will be used to write the results

ct.resultsName = "test"

Step 4: If desired, over-ride selected predefined parameters directly from within the script. For example,

ct.protocol.mA = 200
ct.protocol.enableQuantumNoise = 1

Step 5: Run the desired scans

ct.run_all()

The input phantom images can be viewed using ImageJ, described here.

Results

Simulation results are described on this page.

Running XCIST from the python command line

(Future content)

Running the Windows executable

After downloading the .zip file, un-zip it to a folder of your choice (e.g. I put it directly in C:). Please rename the top-level extracted folder to simply CatSim (it might be named main-master, or main-master (1), or the like).

Browse to that folder, browse to the EXE subdirectory, and double-click on catsim.exe. This should open a command window and run an example simulation. However, if an error occurs, the command window might automatically close. And even when successful, the command window will close when complete.

Therefore, it's preferable to first open a command window, then run the executable.

  1. Type "command" into Windows search, then pin "Command prompt" to your Start menu and/or Taskbar, as you prefer.
  2. Click the "Command prompt" icon to open a command window.
  3. Change directory to the path for the Windows executable (example below).
  4. Type "catsim" (the filename of the executable).
  5. There will be a pause for several seconds as the code initializes, then the simulation should run (example output below).
  6. If you receive a warning message about "The MATPLOTLIBDATA environment variable...", it can safely be ignored.
  7. When the simulation is complete, a plot should open.
  8. Close the plot, and press a key when prompted. After several seconds (while the executable cleans up and closes), you should get a command prompt.

Example:
Note that your command prompt, to the left of the '>', will be different from mine, shown in this example.
Also, the path to the executable (to the right of the '>' in the first line), depends on where you unzipped the executable code that you downloaded.

C:\Users\user_name>cd C:\Catsim\main-master\EXE
C:\Catsim\main-master\EXE>catsim
Airscan
Loading GEANT4/EDLP97 cross section database...compton..rayleigh..photo..scatter..form..done
Scan sim time: 4.5 s
Offset scan
Scan sim time: 0.3 s
Phantom scan
in C> Preparing to allocate memory for material volume data...
in C> Allocated memory for image volume for material  1
in C> Copying data for material  1 into C memory...in C>  done.
in C> Allocated memory for image volume for material  2
in C> Copying data for material  2 into C memory...in C>  done.
in C> Allocated a total of      2 MB.
Simulated view 80/800, time: 10.8 s
Simulated view 160/800, time: 21.4 s
Simulated view 240/800, time: 32.5 s
Simulated view 320/800, time: 43.1 s
Simulated view 400/800, time: 53.5 s
Simulated view 480/800, time: 64.1 s
Simulated view 560/800, time: 74.6 s
Simulated view 640/800, time: 85.8 s
Simulated view 720/800, time: 96.5 s
Simulated view 800/800, time: 107.0 s
Scan sim time: 107.0 s
Prep view
Simulation is done
    
Press any key to continue . . .
    
C:\Catsim\main-master\EXE>

Once complete, you may ask: What happened? What were the inputs and outputs? How do I know it really worked?
You can find answers to those questions and more here: Viewing XCIST image files using ImageJ.


Back to Main menu

⚠️ **GitHub.com Fallback** ⚠️