Using iolite 3/Igor Pro's color tables in iolite 4

· ☕ 3 min read · ✍️ Joe

Missing the color tables of iolite 3/Igor Pro in iolite 4? Read on to find out how you can transfer those color tables from Igor Pro to iolite 4!

Getting the color table data

Start Igor Pro, open the Command Window (Control+J for Windows, Command+J for Mac) and enter the following commands, followed by enter:

1
ColorTab2Wave ColdWarm; edit M_colors

This will open up a table of the red, green and blue values for the specified color table, in this case ‘ColdWarm’. Note that the values are between 0 and 65535, which will be important later.

Table

We can save this data out to a text file by going to Igor Pro’s Data->Save waves->Save delimited text menu item. In the prompt, be sure to uncheck the option to write the wave name as shown below:

Save

Adding it to iolite 4

Now we have the color table data in a format that we can easily read from python in iolite 4. Custom iolite 4 color tables are stored in the settings as a dict of lists, e.g.

1
2
3
color_tables = {
    'ColorTableName': [QColor(1, 2, 3), QColor(4, 5, 6), QColor(7, 8, 9)]
}

Where the parameters for QColor are the red, green, and blue values, but between 0 and 255 rather than 0 and 65535.

Knowing this information, the simple script below can be used to:

  1. Get the existing (custom) color tables from iolite
  2. Ask the user to pick a file
  3. Read the file using pandas
  4. Create a new list of QColors from the file contents while rescaling the values
  5. Ask the user to name the new color table
  6. Write the color tables back to iolite’s settings
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from iolite.QtGui import QFileDialog, QInputDialog, QColor, QLineEdit
from iolite.QtCore import QSettings, QFileInfo
import pandas as pd

# 1
settings = QSettings()
gp = settings.value('Imaging/CustomGradientPresets')
if not gp:
	gp = {}

# 2
fn = QFileDialog.getOpenFileName()

if not fn:
	raise Exception('No file')

# 3
df = pd.read_csv(fn, names=['R', 'G', 'B'], delimiter=' ')
d = []

f = 255./65535.

# 4
for i, r in df.iterrows():
	d.append(QColor(r['R']*f, r['G']*f, r['B']*f))

# 5
name = QInputDialog.getText(None, 'Preset name', 'Preset name', QLineEdit.Normal, QFileInfo(fn).baseName())

if not name:
	raise Exception('No name')

# 6
gp[name] = d
settings.setValue('Imaging/CustomGradientPresets', gp)

In action

After restarting iolite, you will now find your new color map as an option when choosing color scales in imaging. Shown below is our go-to otolith example in Igor Pro’s cold warm.

InAction
Options

If you have any questions, comments or suggestions about this Note, you can discuss it here.


iolite team
WRITTEN BY
Joe
iolite developer


What's on this Page