Skip to content

Commit

Permalink
[NEW 📦] import/export scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
saratheriver committed Mar 10, 2021
1 parent f8c19a2 commit f398837
Show file tree
Hide file tree
Showing 22 changed files with 89 additions and 259,978 deletions.
Binary file modified enigmatoolbox/__pycache__/_version.cpython-37.pyc
Binary file not shown.
7 changes: 5 additions & 2 deletions enigmatoolbox/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from .base import (load_conte69, load_sc, load_fc,
load_fsa5, load_subcortical, structural_covariance,
fetch_ahba, risk_genes, load_example_data,
load_summary_stats, load_fc_as_one, load_sc_as_one)
load_summary_stats, load_fc_as_one, load_sc_as_one,
nfaces, getaffine)

__all__ = ['load_conte69',
'load_fsa5',
Expand All @@ -14,4 +15,6 @@
'load_example_data',
'load_summary_stats',
'load_fc_as_one',
'load_sc_as_one']
'load_sc_as_one',
'nfaces',
'getaffine']
Binary file modified enigmatoolbox/datasets/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file modified enigmatoolbox/datasets/__pycache__/base.cpython-37.pyc
Binary file not shown.
73 changes: 73 additions & 0 deletions enigmatoolbox/datasets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,79 @@ def reorder_sum_stats(in_file, out_file):

return out.to_csv(out_file, index=False)


def nfaces(surface_name, hemisphere):
"""Returns number of faces/triangles for a surface (author: @saratheriver)
Parameters
----------
surface_name : string
Name of surface {'fsa5', 'conte69'}
hemisphere : string
Name of hemisphere {'lh', 'rh', 'both'}
Returns
-------
numfaces : int
number of faces/triangles
"""

if surface_name is 'fsa5':
if hemisphere is 'lh':
return load_fsa5()[0].GetPolys2D().shape[0]
elif hemisphere is 'rh':
return load_fsa5()[1].GetPolys2D().shape[0]
elif hemisphere is 'both':
return load_fsa5()[0].GetPolys2D().shape[0] + load_fsa5()[1].GetPolys2D().shape[0]
elif surface_name is 'conte69':
if hemisphere is 'lh':
return load_conte69()[0].GetPolys2D().shape[0]
elif hemisphere is 'rh':
return load_conte69()[1].GetPolys2D().shape[0]
elif hemisphere is 'both':
return load_conte69()[0].GetPolys2D().shape[0] + load_conte69()[1].GetPolys2D().shape[0]


def getaffine(surface_name, hemisphere):
"""Returns vox2ras transform for a surface (author: @saratheriver)
Parameters
----------
surface_name : string
Name of surface {'fsa5', 'conte69'}
hemisphere : string
Name of hemisphere {'lh', 'rh', 'both'}
Returns
-------
numfaces : 2D ndarray
vox2ras transform, shape = (4, 4)
"""

if surface_name is 'fsa5':
if hemisphere is 'lh' or 'rh':
return np.asarray([[-1.000e+00, 0.000e+00, 0.000e+00, 5.121e+03],
[0.000e+00, 0.000e+00, 1.000e+00, -5.000e-01],
[0.000e+00, -1.000e+00, 0.000e+00, 5.000e-01],
[0.000e+00, 0.000e+00, 0.000e+00, 1.000e+00]])
elif hemisphere is 'both':
return np.asarray([[-1.0000e+00, 0.0000e+00, 0.0000e+00, 1.0242e+04],
[0.0000e+00, 0.0000e+00, 1.0000e+00, -5.0000e-01],
[0.0000e+00, -1.0000e+00, 0.0000e+00, 5.0000e-01],
[0.0000e+00, 0.0000e+00, 0.0000e+00, 1.0000e+00]])
elif surface_name is 'conte69':
if hemisphere is 'lh' or 'rh':
return np.asarray([[-1.0000e+00, 0.0000e+00, 0.0000e+00, 1.6246e+04],
[0.0000e+00, 0.0000e+00, 1.0000e+00, -5.0000e-01],
[0.0000e+00, -1.0000e+00, 0.0000e+00, 5.0000e-01],
[0.0000e+00, 0.0000e+00, 0.0000e+00, 1.0000e+00]])
elif hemisphere is 'both':
return np.asarray([[-1.0000e+00, 0.0000e+00, 0.0000e+00, 3.2492e+04],
[0.0000e+00, 0.0000e+00, 1.0000e+00, -5.0000e-01],
[0.0000e+00, -1.0000e+00, 0.0000e+00, 5.0000e-01],
[0.0000e+00, 0.0000e+00, 0.0000e+00, 1.0000e+00]])


# For every new summary statistic file, run the following command to reorder
# cortical structures according to ENIGMA mega-analysis protocols!

Expand Down
Loading

0 comments on commit f398837

Please sign in to comment.