327 lines
8.2 KiB
HTML
327 lines
8.2 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<title>Code-along: Brain</title>
|
||
<meta name="description" content="Brain-inspired example analysis code">
|
||
<meta name="author" content="The DataLad Team">
|
||
|
||
<meta charset="utf-8">
|
||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
|
||
<!-- Original reveal JS stylesheets-->
|
||
<link rel="stylesheet" href="../reveal.js/dist/reset.css">
|
||
<link rel="stylesheet" href="../reveal.js/dist/reveal.css">
|
||
<link rel="stylesheet" href="../reveal.js/dist/theme/beige.css">
|
||
<!-- custom styles, e.g., imgcredit -->
|
||
<link rel="stylesheet" href="../custom/css/main.css" id="theme">
|
||
<script src="../custom/js/printpdf.js"></script>
|
||
</head>
|
||
<body>
|
||
|
||
<div class="reveal">
|
||
<div class="slides">
|
||
|
||
<section>
|
||
<section id='versioncontrol' style="text-align:left" data-markdown data-transition="none"><script type="text/template">
|
||
## Create a dataset<!-- .element: style="text-align:center" -->
|
||
|
||
Open a terminal and run the following command
|
||
```console
|
||
datalad create -c text2git my-analysis
|
||
```
|
||
|
||
On success, you should see something like
|
||
|
||
```
|
||
create(ok): ... (dataset)
|
||
```
|
||
|
||
What did you get as a result?
|
||
</script></section>
|
||
|
||
<section id='versioncontrol' style="text-align:left" data-markdown data-transition="none"><script type="text/template">
|
||
## Version control<!-- .element: style="text-align:center" -->
|
||
|
||
Take a look inside
|
||
```console
|
||
cd my-analysis
|
||
```
|
||
```console
|
||
ls -la .
|
||
```
|
||
|
||
You should see traces of version control tools.
|
||
Let's use them and version control a file
|
||
|
||
```console
|
||
echo "# My example DataLad dataset" > README.md
|
||
```
|
||
```console
|
||
datalad status
|
||
```
|
||
```console
|
||
datalad save -m "Create a short README"
|
||
```
|
||
</script></section>
|
||
|
||
<section id='versioncontrol' style="text-align:left" data-markdown data-transition="none"><script type="text/template">
|
||
## Version control II<!-- .element: style="text-align:center" -->
|
||
|
||
Make more modifications
|
||
```console
|
||
echo "This dataset contains a toy data analysis" >> README.md
|
||
```
|
||
```console
|
||
git diff
|
||
```
|
||
save them again:
|
||
|
||
```console
|
||
datalad save -m "Add information on the dataset contents to the README"
|
||
```
|
||
|
||
Check the dataset history
|
||
```console
|
||
git log
|
||
```
|
||
</script></section>
|
||
|
||
|
||
<section id='transport' style="text-align:left" data-markdown data-transition="none"><script type="text/template">
|
||
## Data transport<!-- .element: style="text-align:center" -->
|
||
|
||
Let's get some BIDS-structured brain data:
|
||
|
||
```console
|
||
datalad clone -d . \
|
||
https://hub.datalad.org/edu/bids-data.git \
|
||
input
|
||
```
|
||
|
||
Take a look inside:
|
||
|
||
```console
|
||
cd input
|
||
```
|
||
```console
|
||
ls
|
||
```
|
||
What do you notice about the files? Does the size of the dataset give you a hint?
|
||
```console
|
||
du -sh
|
||
```
|
||
```console
|
||
git annex info
|
||
```
|
||
</script></section>
|
||
|
||
<section id='transport' style="text-align:left" data-markdown data-transition="none"><script type="text/template">
|
||
## Data transport II<!-- .element: style="text-align:center" -->
|
||
|
||
File content can exist in a decentral network
|
||
|
||
```console
|
||
git annex info sub-02/func/sub-02_task-oneback_run-01_bold.nii.gz
|
||
```
|
||
```console
|
||
git annex whereis sub-02/func/sub-02_task-oneback_run-01_bold.nii.gz
|
||
```
|
||
You can get or drop annexed file contents depending on your needs:
|
||
|
||
```console
|
||
datalad get sub-02
|
||
```
|
||
```console
|
||
datalad drop sub-02
|
||
```
|
||
</script></section>
|
||
|
||
|
||
|
||
<section id='nesting' style="text-align:left" data-markdown data-transition="none"><script type="text/template">
|
||
## Nesting<!-- .element: style="text-align:center" -->
|
||
|
||
The dataset you cloned has its own history:
|
||
|
||
```console
|
||
git log
|
||
```
|
||
|
||
The top-level dataset only recorded dataset version and availability:
|
||
|
||
```console
|
||
cd ..
|
||
```
|
||
```console
|
||
git log
|
||
```
|
||
|
||
It is a so-called "subdataset"
|
||
|
||
```console
|
||
datalad subdatasets
|
||
```
|
||
|
||
</script></section>
|
||
|
||
|
||
<section id='prov' style="text-align:left" data-markdown data-transition="none"><script type="text/template">
|
||
## Ingredients of a data analysis<!-- .element: style="text-align:center" -->
|
||
|
||
Let's download code to run
|
||
```console
|
||
wget -P code/ \
|
||
https://hub.datalad.org/edu/scripts/raw/branch/main/brains/get_brainmask.py
|
||
```
|
||
|
||
save the script:
|
||
|
||
```console
|
||
datalad status
|
||
```
|
||
```console
|
||
datalad save -m "Adding a nilearn-based script for brain masking"
|
||
```
|
||
</script></section>
|
||
|
||
<section id='prov' style="text-align:left" data-markdown data-transition="none"><script type="text/template">
|
||
## Recording provenance<!-- .element: style="text-align:center" -->
|
||
|
||
A variety of processes can modify files. A simple example: Code formatting
|
||
```console
|
||
black code/get_brainmask.py
|
||
```
|
||
|
||
Version control makes changes transparent:
|
||
|
||
```console
|
||
git diff
|
||
```
|
||
|
||
But its useful to keep track beyond that. Let's discard the latest changes...
|
||
|
||
```console
|
||
git restore code/get_brainmask.py
|
||
```
|
||
... and record precisely what we did
|
||
```console
|
||
datalad run -m "Reformat code with black" \
|
||
"black code/get_brainmask.py"
|
||
```
|
||
</script></section>
|
||
|
||
<section id='prov' style="text-align:left" data-markdown data-transition="none"><script type="text/template">
|
||
## Using provenance<!-- .element: style="text-align:center" -->
|
||
|
||
Take a look at the previously recorded provenance
|
||
```console
|
||
git show
|
||
```
|
||
... and repeat the process
|
||
|
||
```console
|
||
datalad rerun
|
||
```
|
||
</script></section>
|
||
|
||
|
||
<section id='prov' style="text-align:left" data-markdown data-transition="none"><script type="text/template">
|
||
## Software containers<!-- .element: style="text-align:center" -->
|
||
|
||
With the datalad-container extension, we can not only add code or data,
|
||
but also software containers to datasets and work with them.
|
||
Let's add a software container with Python software for later:
|
||
```console
|
||
datalad containers-add nilearn \
|
||
--url shub://adswa/nilearn-container:latest
|
||
```
|
||
|
||
Make the dataset list its containers:
|
||
|
||
```console
|
||
datalad containers-list
|
||
```
|
||
</script></section>
|
||
|
||
|
||
<section id='prov' style="text-align:left" data-markdown data-transition="none"><script type="text/template">
|
||
## Computational provenance<!-- .element: style="text-align:center" -->
|
||
|
||
Software is a key ingredient to data processing.
|
||
Let's run code inside of the software container:
|
||
```console
|
||
datalad containers-run -m "Compute brain mask" \
|
||
-n nilearn \
|
||
--input input/sub-02/func/sub-02_task-oneback_run-01_bold.nii.gz \
|
||
--output "figures/*" \
|
||
--output "sub-02*" \
|
||
"python code/get_brainmask.py"
|
||
```
|
||
Query an individual file how it came to be:
|
||
|
||
```console
|
||
git log sub-02_brain-mask.nii.gz
|
||
```
|
||
|
||
Check if processing is computationally reproducible:
|
||
```console
|
||
datalad rerun
|
||
```
|
||
</script></section>
|
||
|
||
|
||
|
||
|
||
</section>
|
||
</div> <!-- /.slides -->
|
||
</div> <!-- /.reveal -->
|
||
|
||
<script src="../reveal.js/dist/reveal.js"></script>
|
||
<script src="../reveal.js/plugin/notes/notes.js"></script>
|
||
<script src="../reveal.js/plugin/markdown/markdown.js"></script>
|
||
<script src="../reveal.js/plugin/highlight/highlight.js"></script>
|
||
<script src="../custom/js/copy-code.js"></script>
|
||
<script src="../plugin/reveal_external/external/external.js"></script>
|
||
<script>
|
||
// Full list of configuration options available at:
|
||
// https://github.com/hakimel/reveal.js#configuration
|
||
Reveal.initialize({
|
||
// The "normal" size of the presentation, aspect ratio will be preserved
|
||
// when the presentation is scaled to fit different resolutions. Can be
|
||
// specified using percentage units.
|
||
width: 1280,
|
||
height: 960,
|
||
|
||
// Factor of the display size that should remain empty around the content
|
||
margin: 0.1,
|
||
|
||
// Bounds for smallest/largest possible scale to apply to content
|
||
minScale: 0.2,
|
||
maxScale: 1.0,
|
||
|
||
controls: true,
|
||
progress: true,
|
||
history: true,
|
||
center: true,
|
||
|
||
transition: 'slide', // none/fade/slide/convex/concave/zoom
|
||
|
||
// Optional reveal.js plugins
|
||
plugins: [ RevealExternal, RevealMarkdown, RevealHighlight, RevealNotes ]
|
||
|
||
});
|
||
</script>
|
||
|
||
<!-- A footer with a "1" and "home" button to get back to the first slide and the index page -->
|
||
<div id="hidden" style="display:none;">
|
||
<div id="header">
|
||
<div id="footer-left"><a href="#0">1️⃣</a></div>
|
||
<div id="footer-right"><a href="../index.html">🏠</a></div>
|
||
</div>
|
||
</div>
|
||
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
|
||
<script src="../custom/js/headerandfooter.js"></script>
|
||
|
||
</body>
|
||
</html>
|