Skip to content

Commit 2a9a5bc

Browse files
authored
ENH allow setting curvature values when starting webgl viewer (#498)
* ENH allow setting curvature values when starting webgl viewer * Actually set the passed values
1 parent 157d429 commit 2a9a5bc

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed

cortex/webgl/view.py

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
import os
2-
import glob
1+
import binascii
32
import copy
4-
import json
5-
import time
6-
# Now assumes python 3
7-
from queue import Queue
8-
from configparser import NoOptionError
9-
import shutil
10-
import random
113
import functools
12-
import binascii
4+
import glob
5+
import json
136
import mimetypes
7+
import os
8+
import random
9+
import shutil
1410
import threading
11+
import time
1512
import warnings
1613
import webbrowser
14+
from configparser import NoOptionError
15+
16+
# Now assumes python 3
17+
from queue import Queue
18+
1719
import numpy as np
1820
from tornado import web
1921

20-
from .FallbackLoader import FallbackLoader
21-
from .. import utils, options, volume, dataset
22+
from .. import dataset, options, utils, volume
2223
from ..database import db
2324
from . import serve
2425
from .data import Package
26+
from .FallbackLoader import FallbackLoader
2527

2628
try:
2729
cmapdir = options.config.get('webgl', 'colormaps')
@@ -235,7 +237,11 @@ def show(data, types=("inflated", ), recache=False, cmap='RdBu_r', layout=None,
235237
autoclose=None, open_browser=None, port=None, pickerfun=None,
236238
template="mixer.html", overlays_available=None,
237239
overlays_visible=('rois', 'sulci'), labels_visible=('rois', ),
238-
overlay_file=None, title='Brain', **kwargs):
240+
overlay_file=None,
241+
curvature_brightness=None,
242+
curvature_smoothness=None,
243+
curvature_contrast=None,
244+
title='Brain', **kwargs):
239245
"""
240246
Creates a webGL MRI viewer that is dynamically served by a tornado server
241247
running inside the current python process.
@@ -287,6 +293,15 @@ def show(data, types=("inflated", ), recache=False, cmap='RdBu_r', layout=None,
287293
overlay_file : str or None, optional
288294
Custom overlays.svg file to use instead of the default one for this
289295
subject (if not None). Default None.
296+
curvature_brightness : float or None, optional
297+
Brightness of curvature overlay. Default None, which uses the value
298+
specified in the config file.
299+
curvature_smoothness : float or None, optional
300+
Smoothness of curvature overlay. Default None, which uses the value
301+
specified in the config file.
302+
curvature_contrast : float or None, optional
303+
Contrast of curvature overlay. Default None, which uses the value
304+
specified in the config file.
290305
title : str, optional
291306
The title that is displayed on the viewer website when it is loaded in
292307
a browser.
@@ -345,9 +360,12 @@ def show(data, types=("inflated", ), recache=False, cmap='RdBu_r', layout=None,
345360
my_viewopts = dict(options.config.items('webgl_viewopts'))
346361
my_viewopts['overlays_visible'] = overlays_visible
347362
my_viewopts['labels_visible'] = labels_visible
348-
my_viewopts['brightness'] = options.config.get('curvature', 'brightness')
349-
my_viewopts['smoothness'] = options.config.get('curvature', 'webgl_smooth')
350-
my_viewopts['contrast'] = options.config.get('curvature', 'contrast')
363+
my_viewopts['brightness'] = options.config.get('curvature', 'brightness') \
364+
if curvature_brightness is None else curvature_brightness
365+
my_viewopts['smoothness'] = options.config.get('curvature', 'webgl_smooth') \
366+
if curvature_smoothness is None else curvature_smoothness
367+
my_viewopts['contrast'] = options.config.get('curvature', 'contrast') \
368+
if curvature_contrast is None else curvature_contrast
351369

352370
for sec in options.config.sections():
353371
if 'paths' in sec or 'labels' in sec:
@@ -824,7 +842,7 @@ def get_local_client(self):
824842
return client
825843
else:
826844
try:
827-
from IPython.display import display, HTML
845+
from IPython.display import HTML, display
828846
display(HTML('Open viewer: <a href="{0}" target="_blank">{0}</a>'.format(url)))
829847
except:
830848
pass

0 commit comments

Comments
 (0)