Skip to content

Commit

Permalink
ENH allow setting curvature values when starting webgl viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdoc committed Oct 3, 2023
1 parent e07c4b9 commit 8efa523
Showing 1 changed file with 35 additions and 17 deletions.
52 changes: 35 additions & 17 deletions cortex/webgl/view.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import os
import glob
import binascii
import copy
import json
import time
# Now assumes python 3
from queue import Queue
from configparser import NoOptionError
import shutil
import random
import functools
import binascii
import glob
import json
import mimetypes
import os
import random
import shutil
import threading
import time
import warnings
import webbrowser
from configparser import NoOptionError

# Now assumes python 3
from queue import Queue

import numpy as np
from tornado import web

from .FallbackLoader import FallbackLoader
from .. import utils, options, volume, dataset
from .. import dataset, options, utils, volume
from ..database import db
from . import serve
from .data import Package
from .FallbackLoader import FallbackLoader

try:
cmapdir = options.config.get('webgl', 'colormaps')
Expand Down Expand Up @@ -235,7 +237,11 @@ def show(data, types=("inflated", ), recache=False, cmap='RdBu_r', layout=None,
autoclose=None, open_browser=None, port=None, pickerfun=None,
template="mixer.html", overlays_available=None,
overlays_visible=('rois', 'sulci'), labels_visible=('rois', ),
overlay_file=None, title='Brain', **kwargs):
overlay_file=None,
curvature_brightness=None,
curvature_smoothness=None,
curvature_contrast=None,
title='Brain', **kwargs):
"""
Creates a webGL MRI viewer that is dynamically served by a tornado server
running inside the current python process.
Expand Down Expand Up @@ -287,6 +293,15 @@ def show(data, types=("inflated", ), recache=False, cmap='RdBu_r', layout=None,
overlay_file : str or None, optional
Custom overlays.svg file to use instead of the default one for this
subject (if not None). Default None.
curvature_brightness : float or None, optional
Brightness of curvature overlay. Default None, which uses the value
specified in the config file.
curvature_smoothness : float or None, optional
Smoothness of curvature overlay. Default None, which uses the value
specified in the config file.
curvature_contrast : float or None, optional
Contrast of curvature overlay. Default None, which uses the value
specified in the config file.
title : str, optional
The title that is displayed on the viewer website when it is loaded in
a browser.
Expand Down Expand Up @@ -345,9 +360,12 @@ def show(data, types=("inflated", ), recache=False, cmap='RdBu_r', layout=None,
my_viewopts = dict(options.config.items('webgl_viewopts'))
my_viewopts['overlays_visible'] = overlays_visible
my_viewopts['labels_visible'] = labels_visible
my_viewopts['brightness'] = options.config.get('curvature', 'brightness')
my_viewopts['smoothness'] = options.config.get('curvature', 'webgl_smooth')
my_viewopts['contrast'] = options.config.get('curvature', 'contrast')
if curvature_brightness is None:
my_viewopts['brightness'] = options.config.get('curvature', 'brightness')
if curvature_smoothness is None:
my_viewopts['smoothness'] = options.config.get('curvature', 'webgl_smooth')
if curvature_contrast is None:
my_viewopts['contrast'] = options.config.get('curvature', 'contrast')

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

0 comments on commit 8efa523

Please sign in to comment.