I copy and paste the code into a file and save it into the location e.g., Desktop\record.py (full path). But when I run the code in Python interactor → execfile(‘Desktop\record.py’) it throws errors
File “”, line 1, in
IOError: [Errno 2] No such file or directory: ‘C:\Users\Desktop\record.py’
Here is the line that displayed from my Python interactor.
Python 2.7.13 (default, Dec 20 2017, 00:45:45) [MSC v.1800 64 bit (AMD64)] on win32
I wonder if anybody can give me any hint on this issue?
Note that you can record slice sweeps into a series of png files, animated gif, or video by using ScreenCapture module. You can also use ScreenCapture module from script, for example:
The easiest is to set the image size and zoom to include as much of the image and borders as you need.
Also note that this kind of exported data must not be used for further processing, only for visualization in presentations, etc. (for many reasons, including reduced bit depth, resampling, lack of image spacing information and other metadata).
If you use Matlab then you can run MatlabBridge extension to run Matlab functions directly from Slicer. Or, you can also use nrrdread.m function to read volumes saved in Slicer into Matlab (https://github.com/PerkLab/SlicerMatlabBridge/tree/master/MatlabCommander/commandserver). In the long term, you may consider switching from Matlab to Python, as Python can do almost everything as Matlab can, but Python has many advantages.