Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH allow setting curvature values when starting webgl viewer #498

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
my_viewopts['brightness'] = options.config.get('curvature', 'brightness') \
if curvature_brightness is None else curvature_brightness
my_viewopts['smoothness'] = options.config.get('curvature', 'webgl_smooth') \
if curvature_smoothness is None else curvature_smoothness
my_viewopts['contrast'] = options.config.get('curvature', 'contrast') \
if curvature_contrast is None else 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
Loading