Imaris Open - Discussion Forum

This is a community discussion space where Imaris is the key topic. This forum will offer guidance to new users, technical as well as application support. Users from sites with a valid Imaris Infinity subscription will receive priority – however, the fastest way to get to the Bitplane Technical and Application Support team will continue to be via Asia, EU or US support mailboxes. Every registered user can add items to the forum. Non-registered users can read the forum but cannot add/comment, etc. All ideas, questions, suggestions and comments are welcome.

Advanced Search
Thread Author
Max. Age of Thread
Number of Posts
Thread Rating
HomeHomeXTensionsXTensionsPythonPythonRunning python XTensions from the python shellRunning python XTensions from the python shell
New Post
Running python XTensions from the python shell
 
If you develop python XTensions, you might want to connect to Imaris from python directly,
rather than starting the XTension from the Imaris menu. This post explains how to set up python to do so.

In order to call python XTensions from the python shell, python needs to be set up correctly. There are two things to consider:
1. The PATH environment variable needs to contain the folder of the Imaris executable.
2. The PYTHONPATH environment variable needs to contain the XT/python and XT/python/private folder.

Assuming you have python installed in C:\python27 and Imaris 8.4.1 installed in
C:\Program Files\Bitplane\Imaris x64 8.4.1, you can create a file called startPythonImaris.bat with the following content
(all between the --- marks, not including them):

---
@echo off

set IMARISVERSION=8.4.1
set PYTHONFOLDER=C:\Python27

set IMARISFOLDER=C:\Program Files\Bitplane\Imaris x64 %IMARISVERSION%
set PATH=%IMARISFOLDER%;%PATH%

set PYTHONPATH=%IMARISFOLDER%\XT\python;%IMARISFOLDER%\XT\python\private;%PYTHONPATH%

%PYTHONFOLDER%\python.exe %PYTHONFOLDER%\Lib\idlelib\idle.pyw
---

Save this file, be sure that the file extension is actually .bat, and not .bat.txt, like some text editors automatically do.

Execute the Windows Command Processor (cmd) from the Windows Start Menu,
Navigate to the folder where startPythonImaris.bat is located
Execute startPythonImaris.bat, this will open the python shell.

To check that everything is set up fine, you can import the ImarisLib module:

import ImarisLib

There should be no output to that command. If you get the folloowing error, something is wrong with the setup.
In that case make sure that the paths are correct.
--
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import ImarisLib
ImportError: No module named ImarisLib
---

If all is fine you can now access the sample python XTensions:

Open Imaris and load some image. Run the sample XTension:

import XTSimpleSpotsExample
XTSimpleSpotsExample.XTSimpleSpotsExample(0)
 
Note that when you have multiple Imaris instances open, you have to choose the appropriate Imaris ID instead of 0.

You have now set up Imaris and python so that you can change the XTSimpleSpotsExample.py python file and just call it from the python shell.

When you change a python file you need restart python or call

reload(XTSimpleSpotsExample)

for the changes to take effect (import XTSimpleSpotsExample is not enough).
 
Copy Post URL
Sacha Guyer wrote:
...

To check that everything is set up fine, you can import the ImarisLib module:

import ImarisLib

There should be no output to that command. If you get the folloowing error, something is wrong with the setup.
In that case make sure that the paths are correct.
--
Traceback (most recent call last):
  File " ", line 1, in
    import ImarisLib
ImportError: No module named ImarisLib
---

...

Also be sure to use 64-bit Python if you are on a 64-bit Windows OS.  The default download from python.org is 32-bit, and this will throw an error when you 'import ImarisLib'.  

The error message (if  you are using 32-bit Python) concludes with "DLL load failed: %1 is not a valid Win32 application."




 
Copy Post URL
MAC SCRIPT

For connecting to Imaris from the Mac terminal, use the following script.

It is assumed that you have Imaris 9.1.2 installed. For other Imaris versions, adjust VERSION in the script accordingly.

I assume you have your own python scripts in your Documents/myImarisXTensions folder.
In that folder, create a file called startpythonForImarisMAC.sh with the following content (without the --):
--
#!/bin/bash

# make this file executable with the following line:
# chmod +x startpythonForImarisMAC.sh

# start this file from the Terminal application with the following line:
# ./startpythonForImarisMAC.sh
VERSION="9.1.2"
FOLDER="/Applications/Imaris ${VERSION}.app/Contents/SharedSupport/XT/python"

# add the python/private folder to python path for python ice support
export PYTHONPATH=${FOLDER}:${FOLDER}/private

#start python
python
--
make the file executable with chmod +x startpythonForImarisMAC.sh

To test this script:
- Copy the file XTSimpleSpotsExample.py from /Applications/Imaris 9.1.2.app/Contents/SharedSupport/XT/python/ to Documents/myImarisXTensions
- Start the Terminal app
- Change to the folder /Users/${USER}/Documents/myImarisXTensions
- Start Imaris and open the retina.ims dataset
- Launch the script with ./startpythonForImarisMAC.sh

-> You are now in the python shell with access to the Imaris XT python library

- To check that everything is set up fine, import ImarisLib with the following command:
import ImarisLib
There should be no output to that command.

- Load the python sample file XTSimpleSpotsExample
import XTSimpleSpotsExample

- Execute the sample file:
XTSimpleSpotsExample.XTSimpleSpotsExample(0)

This should generate a spot in the center of the loaded image

You can now adjust the XTSimpleSpotsExample script or create a new one in that folder

When you change a python file you need restart python or call

reload(XTSimpleSpotsExample)

for the changes to take effect (import XTSimpleSpotsExample is not enough).
 
Copy Post URL


Post URL:
casque beats pas cher casque beats by dre pas cher beats by dre pas cher beats by dre pas cher maillot foot pas cher maillot de foot pas cher maillot foot pas cher 2014 maillot de foot pas cher maillot foot pas cher maillot de foot pas cher maillot foot pas cher 2014 maillot de foot pas cher maillot foot pas cher 2014 maillot de foot pas chere maillot foot pas cher maillot de foot pas cher Ralph Lauren Homme Polo Manche Longue Ralph Lauren Polo Ralph Lauren Pas Cher Homme Polo Ralph Lauren Homme Pas Cher Ralph Lauren Soldes Ralph Lauren Big Pony Ralph Lauren Soldes Ralph Lauren Big Pony Ralph Lauren Soldes Ralph Lauren Big Pony Ralph Lauren Soldes Ralph Lauren Big Pony