예제 #1
0
def test_dataset_save():
	tf = tempfile.NamedTemporaryFile(suffix=".hdf")
	ds = cortex.Dataset(test=(np.random.randn(31, 100, 100), subj, xfmname))
	ds.save(tf.name)
	
	ds = cortex.openFile(tf.name)
	assert isinstance(ds.test, cortex.DataView)
	assert ds.test.data.shape == (31, 100, 100)
예제 #2
0
def test_mask_save():
	tf = tempfile.NamedTemporaryFile(suffix=".hdf")
	ds = cortex.Dataset(test=(np.random.randn(31, 100, 100), subj, xfmname))
	ds.append(masked=ds.test.data.masked['thin'])
	data = ds.masked.data.data
	ds.save(tf.name)

	ds = cortex.openFile(tf.name)
	assert ds.masked.data.shape == (31, 100, 100)
	assert np.allclose(ds.masked.data.data, data)
예제 #3
0
def test_view_multi():
	ds1 = cortex.VolumeData(np.random.randn(31, 100, 100), subj, xfmname)
	ds2 = cortex.VolumeData(np.random.randn(31, 100, 100), subj, xfmname)
	ds3 = cortex.VolumeData(np.random.randn(31, 100, 100), subj, xfmname)

	tf = tempfile.NamedTemporaryFile(suffix=".hdf")
	ds = cortex.Dataset(view1=[(ds1, ds2)], view2=[(ds1, ds3)], view3 = ds3)
	ds.save(tf.name)

	ds = cortex.openFile(tf.name)
	assert len(ds.view1.data) == 1
	assert len(ds.view2.data) == 1
	assert isinstance(ds.view3.data, cortex.VolumeData)
예제 #4
0
def test_pack():
	tf = tempfile.NamedTemporaryFile(suffix=".hdf")
	ds = cortex.Dataset(test=(np.random.randn(31, 100, 100), subj, xfmname))
	ds.save(tf.name, pack=True)

	ds = cortex.openFile(tf.name)
	pts, polys = cortex.surfs.getSurf(subj, "fiducial", "lh")
	dpts, dpolys = ds.getSurf(subj, "fiducial", "lh")
	assert np.allclose(pts, dpts)

	rois = cortex.surfs.getOverlay(subj, "rois")
	assert rois.rois.keys() == ds.getOverlay(subj, "rois").rois.keys()

	xfm = cortex.surfs.getXfm(subj, xfmname)
	assert np.allclose(xfm.xfm, ds.getXfm(subj, xfmname).xfm)
예제 #5
0
######### CONFIG START
dbg_mode = False
defsz = (960, 540) #(1920, 1080)
delay_before_start = 30
port = 22648
fps = 30
bitrate = '2000k'
fnamepre = 'brainmovie'

fnamepattern='%s%%07d.png' % (fnamepre)

eg_datafile = path.join('data', 'S1_retinotopy.hdf')
######### CONFIG END

print 'opening eg file (%s)...'%(eg_datafile)
egds = cortex.openFile(eg_datafile)
print '...done'

#print 'quickshow random'
#im = cortex.quickshow((np.random.randn(31, 100, 100), "S1", "fullhead"))

print 'webshow, setting up server...'
js_handle = cortex.webgl.show(egds, port=port, open_browser=False)
print '...done'

print 'getting client... open a web browser to localhost:%d'%(port)
js_client = js_handle.get_client() #this will block until a browser has opened
# Start with left hemisphere view
#js_client._set_view(azimuth=[90],altitude=[90.5],mix=[0])
js_client.setState('labels', False)
#js_client.setState('alpha', 0)