Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • fsl/pytreat-practicals-2020
  • mchiew/pytreat-practicals-2020
  • ndcn0236/pytreat-practicals-2020
  • nichols/pytreat-practicals-2020
4 results
Show changes
Showing
with 3225 additions and 52 deletions
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Getting started
===============
This directory contains the "Getting started" practical.
This directory contains the _Getting started_ practical, intended for those of
you who are new to Python as a language, or want a refresher on how it all
works.
If you are already comfortable with Python, `numpy`, `nibabel`, and `jupyter`.
then you might want to check out the `advanced_topics` folder.
1. Python basics (MJ)
2. Text input/output (MC)
......@@ -9,5 +17,5 @@ This directory contains the "Getting started" practical.
4. Numpy (PM)
5. Nifti images (MJ)
6. Image manipulation (MC)
7. Jupyter notebook and Ipython(MC)
7. Jupyter notebook and IPython (MC)
8. Writing a callable script (MJ)
File added
#!/usr/bin/env fslpython
# That first line up there ensures that your
# script will be executed in the fslpython
# environment. If you are writing a general
# Python script, you should use this line
# instead: #!/usr/bin/env python
# In Python, we need to "import" libraries
# (called modules) before we can use them.
import sys
import nibabel as nib
# We can get to our command
# line arguments via sys.argv
fpath = sys.argv[1]
# We can use nibabel to load
# NIFTI images (and other
# neuroimaging data formats)
img = nib.load(fpath)
data = img.get_data()
# Now we're working with a
# numpy array.
nzmean = data[data != 0].mean()
print('mean:', nzmean)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
talks/matlab_vs_python/migp/concat_diag.png

27.1 KiB

This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.