Instantly share code, notes, and snippets.
Last active
December 17, 2015 15:19
-
Save beOn/5631069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "TestAnalysis" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Some setup..." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"from parseBehav import parseBhLog\n", | |
"from mvpa2.suite import *\n", | |
"\n", | |
"PROCS_OF_INTEREST = ['MixedBivalent1', 'MixedBivalent2', 'MixedBivalent3',\n", | |
" 'MixedUnivalent1', 'MixedUnivalent2', 'MixedUnivalent3']\n", | |
"\n", | |
"FILES = [\"testbold%02d.nii\" % n for n in xrange(1,11)]\n", | |
"\n", | |
"sas, events = parseBhLog('./testbehav.txt')\n", | |
"events = [ev for ev in events if ev['ev_block_proc'] in PROCS_OF_INTEREST]\n", | |
"\n", | |
"ds = fmri_dataset(FILES, mask='testroi.nii')\n", | |
"\n", | |
"for key in sas.keys(): ds.sa[key] = sas[key]" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Vanilla event related dataset..." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"dse = eventrelated_dataset(ds,events=events)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 3 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"print dse.nsamples\n", | |
"print dse.nfeatures\n", | |
"vi = dse.fa['voxel_indices']\n", | |
"print vi[0]\n", | |
"# all voxel indices repeated twice?\n", | |
"nFeats = int(floor(dse.nfeatures/2))\n", | |
"print all([vi[i] == vi[nFeats+i] for i in xrange(nFeats)])" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"192\n", | |
"1140\n", | |
"[23 31 6]\n", | |
"True\n" | |
] | |
} | |
], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"This all looks good." | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Now let's use FxMapper to do a little temporal compression..." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"fx = FxMapper(axis='features', fx=np.mean)\n", | |
"dse2 = eventrelated_dataset(ds,events=events,event_mapper=fx)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 5 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"print dse2.nsamples\n", | |
"print dse2.nfeatures\n", | |
"# all voxel indices equal to mean of same voxels from\n", | |
"# the two volumes?\n", | |
"nSamps = dse2.nsamples\n", | |
"s1 = dse.samples\n", | |
"s2 = dse2.samples\n", | |
"print all([[s2[n,i] == np.mean([s1[n,i], s1[n,nFeats+i]]) for i in xrange(nFeats)] for n in xrange(nSamps)])" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"192\n", | |
"570\n", | |
"True" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n" | |
] | |
} | |
], | |
"prompt_number": 6 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"This looks good too. Everything is averaged correctly." | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Let's check to see if the voxel indices are intact..." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"print dse.fa['voxel_indices'][0]\n", | |
"print dse2.fa['voxel_indices'][0]" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"[23 31 6]\n", | |
"6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41\n" | |
] | |
} | |
], | |
"prompt_number": 7 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Okay, lost me there. Where does this value come from?" | |
] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment