CatSim Python IDE setup - xcist/documentation GitHub Wiki
Option 1 - VSCode (Visual Studio Code)
- Install VSCode: https://code.visualstudio.com/download
- Open VSCode, install Python Extensions
- When you open your Python file in VSCode, from the bottom right, select your Python interpreter
Option 2 - PyCharm
- Download from https://www.jetbrains.com/pycharm/. After downloading, follow Setting up Pycharm to set up your environment.
Test CatSim
Run one or more of the example programs to confirm that you have the python dependencies setup correctly.
Option 1 - IDE (e.g., Pycharm)
- Right click on the
examples/Sim_Sample.py
file and click Run 'Sim_Sample'.
Output will be written to the Run window. A plot window will be opened. Click to close it after review.
Option 2 - Command line
cd examples
python Sim_Sample.py
Sample output (times may vary)
Airscan
Scan sim time: 1.3 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 8 MB.
Simulated view 5/50, time: 8.9 s
Simulated view 10/50, time: 18.0 s
Simulated view 15/50, time: 28.1 s
Simulated view 20/50, time: 37.8 s
Simulated view 25/50, time: 45.9 s
Simulated view 30/50, time: 54.1 s
Simulated view 35/50, time: 63.1 s
Simulated view 40/50, time: 72.8 s
Simulated view 45/50, time: 82.2 s
Simulated view 50/50, time: 90.3 s
Scan sim time: 90.3 s
Prep view
Simulation is done
A plot window will open up. Close it to finish the program.
Updating CatSim
If you are using PyCharm, you can update the code and then rerun.
If you are using the command-line, rebuild catsim before rerunning. This will update your installed version of catsim-xcist.
pip install . --use-feature=in-tree-build
If you are using the PyPI installation, you can run this command to upgrade:
pip install -U gecatsim
If you have changes to share back to GitHub, create a branch and the submit a GitHub pull request. Please increment the version in setup.py and catsim/init.py.
Data file search paths
CatSim will look in the following locations for data files, including config, phantoms, materials, etc.
- A file matching the name as written.
- A file matching the name as written with the default extension for the type of file.
- A list of extra search paths. The paths will be searched recursively.
- A file that matches the name as written in the search path.
- A file that matches the name as written in the search path with the default extension for the type of file.
- A file that matches the name as written in a subdirectory with the file type key (e.g. cfg, phantom, etc.)
- A file that matches the name as written in a subdirectory with the file type key and the default extension.
- The path to the catsim code directory. This path will be searched recursively.
- A file that matches the name as written in the default path.
- A file that matches the name as written in the default path with the default extension for the file type.
The extra search paths can be defined by creating a file called .catsim. This file can be placed in the directory where you are running main catsim file (e.g. examples). The .catsim file can also be placed in the user's home directory.
If you write your own python script, you can also call the add_search_path function with code like:
import gecatsim as xc
##--------- Initialize
my_path = xc.pyfiles.CommonTools.my_path
# add any additional search directories
my_path.add_search_path("my-experiments")