Skip to content

Commit

Permalink
Fixed non-existent normalization for raw (RGB) volumes, small steps t…
Browse files Browse the repository at this point in the history
…oward getting dotted lines in webgl view
  • Loading branch information
marklescroart committed Nov 5, 2014
1 parent a5f75e3 commit 6c203f4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ scripts

# C extensions
*.so
formats.c
openctm.c

# Packages
*.egg
Expand Down
3 changes: 2 additions & 1 deletion cortex/dataset/braindata.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ def volume(self):
def save(self, filename, name=None):
"""Save the dataset into an hdf file with the provided name
"""
import os
if isinstance(filename, str):
fname, ext = os.path.splitext(filename)
if ext in (".hdf", ".h5"):
if ext in (".hdf", ".h5",".hf5"):
h5 = h5py.File(filename, "a")
self._write_hdf(h5, name=name)
h5.close()
Expand Down
10 changes: 8 additions & 2 deletions cortex/dataset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,14 @@ def raw(self):
cm.register_cmap(self.cmap,cmap)
else:
cmap = cm.get_cmap(self.cmap)
norm = colors.Normalize(self.vmin, self.vmax) # Does this do anything?
return np.rollaxis(cmap(self.data), -1)
elif isinstance(self.cmap,colors.Colormap):
cmap = self.cmap
# Normalize colors according to vmin, vmax
norm = colors.Normalize(self.vmin, self.vmax)
cmapper = cm.ScalarMappable(norm=norm, cmap=cmap)
color_data = cmapper.to_rgba(self.data.flatten()).reshape(self.data.shape+(4,))
# rollaxis puts the last color dimension first, to allow output of separate channels: r,g,b,a = dataset.raw
return np.rollaxis(color_data, -1)

class Multiview(Dataview):
def __init__(self, views, description=""):
Expand Down
3 changes: 3 additions & 0 deletions cortex/quickflat.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ def make_figure(braindata, recache=False, pixelwise=True, thick=32, sampler='nea
cm.register_cmap(dataview.cmap,cmap)
else:
cmap = dataview.cmap
elif isinstance(dataview.cmap,colors.Colormap):
# Allow input of matplotlib colormap class
cmap = dataview.cmap
kwargs.update(
cmap=cmap,
vmin=dataview.vmin,
Expand Down
14 changes: 13 additions & 1 deletion cortex/webgl/resources/js/svgroi.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,20 @@ ROIpack.prototype = {
lc = "stroke:" + lc;
lw = "stroke-width:" + lw + "px";
sw = parseInt(sw);


//WIP!
//style_array = [fo, lo, fc, lc, lw]
//(Then set style_array per path?) or set style first, then only update strokeDasharray per path?
oldstyle = this.layers[layer].attr("style")
console.log(oldstyle) // Hrm. This appears to be too late - the style has already been set before this prints out. Why?
// ...I thought this next line set the style...?
this.layers[layer].attr("style", [fo, lo, fc, lc, lw].join(";"));
// loop over paths
// PROBLEM: Still need to find wth the read-in svg line styles are. Must be where we got paths... but fuck if I know.
// for (var pth=0; pth<disp_layers[layer].length; pth++){
// this.layers[layer][pth].strokeDasharray=olddasharray
// this.layers[layer][pth].disp_layers[]
// }
}

var svg_xml = (new XMLSerializer()).serializeToString(this.svgroi);
Expand Down

0 comments on commit 6c203f4

Please sign in to comment.