Skip to content

Commit a2a4bf8

Browse files
committed
docs: revise #32
1 parent a9cf3df commit a2a4bf8

File tree

6 files changed

+111
-101
lines changed

6 files changed

+111
-101
lines changed

docs/contributing_tutorials/adding_a_new_template.rst

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1+
.. _adding-new-template:
2+
13
Creating a new template space
2-
###############################################
4+
=============================
35

4-
Who is this tutorial for
5-
============================
6+
.. admonition :: Who is this tutorial for?
67
7-
First, this is intended for those wishing to add templates to TemplateFlow.
8-
Second, this is for people who want to add a template directory that does not already exists.
9-
TemplateFlow consists of multiple templates sorted by the space the template is in.
10-
This tutorial tells you how to add a new template space.
8+
First, this is intended for those wishing to add templates to TemplateFlow.
9+
Second, this is for people who want to add a template directory that does not already exists.
10+
TemplateFlow consists of multiple templates sorted by the space the template is in.
11+
This tutorial tells you how to add a new template space.
1112
12-
If the space for you template already exists, then you should follow the tutorial: :ref: `uploading_to_existing_templates`.
13+
If the space for you template already exists, then you should follow the tutorial: :ref:`upload-to-existing`.
1314
14-
This tutorial assumes you have done all the steps in the preceding tutorial: :ref: `prerequisites_to_contributing`.
15+
This tutorial assumes you have done all the steps in the preceding tutorial: :ref:`prerequisites-contributing`.
1516
16-
**Note** at present, this tutorial will require writing access to the TemplateFlow repo.
17-
If you do not have access here, it may be best to open up an issue asking for a template space to be created.
17+
**Note** at present, this tutorial will require writing access to the TemplateFlow repo.
18+
If you do not have access here, it may be best to open up an issue asking for a template space to be created.
1819
1920
Step 1: create a new dataset
20-
=============================
21-
21+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2222
First make sure you are in your local templateflow directory.
2323
If you do not have a local templateflow copy, run:
2424

@@ -33,31 +33,30 @@ Finally, write a description of your template.
3333

3434
.. code-block:: bash
3535
36-
TEMPALTENAME='tpl-test'
36+
TEMPLATENAME='tpl-test'
3737
GITHUBUSERNAME='yourusername'
38-
TEMPALTEDESCRIPTION="This is a test template"
38+
TEMPLATEDESCRIPTION="This is a test template"
3939
GITHUBREPO='templateflow'
4040
41-
At the moment, always keep templateflow as GITHUBREPO, this may be changed in the future.
41+
At the moment, always keep templateflow as ``GITHUBREPO``, this may be changed in the future.
4242

4343
With these variables set you can then run the following code with no modifications:
4444

4545
.. code-block:: bash
4646
47-
datalad create -d . -D "$TEMPALTEDESCRIPTION" $TEMPALTENAME
48-
cd $TEMPALTENAME
49-
datalad create-sibling-github --github-organization $GITHUBREPO --github-login $GITHUBUSERNAME --access-protocol ssh $TEMPALTENAME
47+
datalad create -d . -D "$TEMPLATEDESCRIPTION" $TEMPLATENAME
48+
cd $TEMPLATENAME
49+
datalad create-sibling-github --github-organization $GITHUBREPO --github-login $GITHUBUSERNAME --access-protocol ssh $TEMPLATENAME
5050
cd ..
51-
sed -i -e "s/url = .\/$TEMPALTENAME/url = https:\/\/github.com\/$GITHUBREPO\/$TEMPLATENAME/g" .gitmodules
51+
sed -i -e "s/url = .\/$TEMPLATENAME/url = https:\/\/github.com\/$GITHUBREPO\/$TEMPLATENAME/g" .gitmodules
5252
datalad save -m "set the github repo url for new template ``$TEMPLATENAME``"
5353
datalad publish
5454
5555
You will be asked to enter your github username and password while running this code.
5656

5757
Explanation of above code
58-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59-
60-
After running, this code will create an empty datalad folder called ``tpl-test`` (or whatever TEMPLATENAME is set to).
58+
.........................
59+
After running, this code will create an empty datalad folder called ``tpl-test`` (or whatever ``TEMPLATENAME`` is set to).
6160
It will then change into that directory, upload the template to github.
6261
It will then return to the templateflow directory.
6362

@@ -77,13 +76,12 @@ with:
7776
path = tpl-test
7877
url = https://github.com/templateflow/tpl-test
7978
80-
I.e. it adds a full url link to the.
79+
I.e., it adds a full url link to the.
8180
The final two lines upload this change.
8281

8382
Step 2: Add a template_description.json
84-
========================================
85-
86-
Within this directory we place a template_description.json which is needed in all templates.
83+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84+
Within this directory we place a ``template_description.json`` which is needed in all templates.
8785
The json file contains the following:
8886

8987
.. code-block:: json
@@ -109,5 +107,5 @@ The json file contains the following:
109107
}
110108
}
111109
112-
Add all the necessary information into the .json file.
110+
Add all the necessary information into the ``.json`` file.
113111
Then open a pull request on github to submit this information.

docs/contributing_tutorials/prerequisites_to_contributing.rst

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,72 @@
1+
.. _prerequisites-contributing:
12

23
Prerequisites to contributing templates to TemplateFlow
3-
############################################################
4+
=======================================================
45

5-
Who is this tutorial for?
6-
=================================
6+
.. admonition :: Who is this tutorial for?
77
8-
Have a template that you would like to see on TemplateFlow? Great!
9-
Contributions are welcome.
10-
This document goes through some of the prerequisites needed to submit a template.
11-
Once you have these prerequisites achieved.
8+
Have a template that you would like to see on TemplateFlow? Great!
9+
Contributions are welcome.
10+
This document goes through some of the prerequisites needed to submit a template.
11+
Once you have these prerequisites achieved.
1212
1313
Are you allowed to share the template?
14-
==========================================
15-
14+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1615
Templates have a licence which specifies the terms that they can be shared.
1716
TemplateFlow can only include templates that allow for redistribution.
18-
It is okay if the template requires attribution, but you need to make sure to add the attribution information.
17+
It is okay if the template requires attribution, but you need to make sure to
18+
add the attribution information into the ``template_description.json`` file.
1919

2020
What type of contribution are you making?
21-
============================================
22-
21+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2322
There are three different types of contributions you can make to TemplateFlow.
2423

25-
**A new template space**.
26-
This contribution involves adding a new space that does not currently exist.
27-
Let us say you have made a new pediatric space that you transform your images to; this would be a new template space.
28-
All the different MNI templates are each considered their own template space.
29-
Currently this requires writing permissions to the TemplateFlow repo.
30-
For now, if you do not have access open up an issue in the templateflow repo to say which template spaces should be added.
24+
A new template space
25+
This contribution involves adding a new space that does not currently exist.
26+
Let us say you have made a new pediatric space that you transform your images to; this would be a new template space.
27+
All the different MNI templates are each considered their own template space.
28+
Currently this requires writing permissions to the TemplateFlow repo.
29+
For now, if you do not have access open up an issue in the templateflow repo
30+
to say which template spaces should be added.
3131

32-
**Nifti images within an existing template space**.
33-
This contribution involves adding to a template space that currently exists.
34-
An example of this would be adding a nifti file that is an atlas.
35-
You need to know which template space your atlas is in (Note: there are multiple MNI spaces).
32+
NIfTI images within an existing template space
33+
This contribution involves adding to a template space that currently exists.
34+
An example of this would be adding a nifti file that is an atlas.
35+
You need to know which template space your atlas is in (Note: there are multiple MNI spaces).
3636

37-
**Meta information**.
38-
This contribution involves additional information about existing templates.
39-
These will generally be in .json or .tsv files.
40-
There are also transform files which help translate between templates.
37+
Meta information
38+
This contribution involves additional information about existing templates.
39+
These will generally be in ``.json`` or ``.tsv`` files.
40+
There are also transform files which help translate between templates.
4141

4242
There are tutorials for each of these three different types of contributions.
4343

4444
Prerequisites for uploading nifti files
45-
=====================================================
46-
47-
Aside from typical requirements (python3, git, pip), some prerequisites need addressing before you can upload a template (i.e. any image file).
45+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46+
Aside from typical requirements (Python, git, pip), some prerequisites need addressing
47+
before you can upload a template (i.e. any image file).
4848

49-
1. Getting access to the OSF repository. Create an issue stating you would like to access to the OSF repo. You need an account at: `osf.io <https://osf.io>`_
49+
1. Getting access to the OSF repository.
50+
Create an issue stating you would like to access to the OSF repo.
51+
You need an account at: `osf.io <https://osf.io>`__.
5052
2. Download the OSF client: ``pip install osfclient``.
51-
3. Install `DataLad <https://www.datalad.org>`_. See the `installation page <https://www.datalad.org/get_DataLad.html>`_ for more details.
52-
4. You also need TemplateFlows DataLad/osf tools. To install these type in a terminal: ``pip install git+https://github.com/TemplateFlow/DataLad-osf``.
53+
3. Install `DataLad <https://www.datalad.org>`_.
54+
See the `installation page <https://www.datalad.org/get_DataLad.html>`_ for more details.
55+
4. You also need TemplateFlow's DataLad/OSF tools.
56+
To install these type in a terminal: ``pip install git+https://github.com/TemplateFlow/DataLad-osf``.
5357

5458
After installing these tools, you are ready to upload a template.
5559

56-
If you only plan to contribute metadata (e.g. json files and tsv files), then these three steps are not needed.
60+
If you only plan to contribute metadata (e.g. JSON files and TSV files), then these three steps are not needed.
5761

5862
Initializing the TemplateFlow OSF directory
59-
==================================================
60-
63+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6164
Once you have the prerequisites set up, you can initialize the OSF directory onto your computer.
6265

6366
In a new directory type:
6467

6568
.. code-block:: bash
66-
69+
6770
osf init
6871
6972
This will prompt you for your username and TemplateFlow project number.

docs/contributing_tutorials/uploading_to_existing_template.rst

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
1-
Uploading files to an existing template space
2-
###############################################
3-
4-
Who is this tutorial for
5-
============================
1+
.. _upload-to-existing:
62

7-
First, this is intended for those wishing to upload templates to TemplateFlow.
8-
Second, this is for people who want to add to a template directory that already exists.
9-
TemplateFlow consists of multiple templates sorted by the space the template is in.
3+
Uploading files to an existing template space
4+
=============================================
105

11-
If the space for you template does not exist, then you should follow this tutorial: :ref: `adding_a_new_template`.
6+
.. admonition :: Who is this tutorial for?
127
13-
This tutorial assumes you have done all the steps in the preceding tutorial: :ref: `prerequisites_to_contributing`.
8+
First, this is intended for those wishing to upload templates to TemplateFlow.
9+
Second, this is for people who want to add to a template directory that already exists.
10+
TemplateFlow consists of multiple templates sorted by the space the template is in.
11+
If the space for you template does not exist, then you should follow :ref:`adding-new-template`.
12+
This tutorial assumes you have done all the steps in the preceding tutorial:
13+
:ref:`prerequisites-contributing`.
1414
1515
Big picture
16-
===============
17-
18-
Image files (e.g. nifti files) are hosted on OSF.
19-
All other information (e.g. tsv, json files) will be hosted on github as regular files.
16+
~~~~~~~~~~~
17+
Image files (e.g. NIfTI files) are hosted on OSF.
18+
All other information (e.g. TSV, JSON files) will be hosted on github as regular files.
2019

2120
When you use TemplateFlow, the images are only downloaded when they are needed.
2221
This can be done with DataLad, DataLad tracks a dataset and only downloads files when they are needed.
23-
You can read more about DataLad `here <https://www.datalad.org>`_.
22+
You can read more about DataLad `here <https://www.datalad.org>`__.
2423

2524
Thus, when uploading to an existing template, there are two different steps:
2625

2726
1. You need to place them on the OSF server.
2827
2. you need to tell DataLad about the new items so the Github repo can track the new files.
2928

3029
Step 1: Placing the template on the OSF server
31-
================================================
30+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3231

3332
Go to the TemplateFlow directory you previously initialized.
3433
Place the file you want to upload in directory and give them appropriate .
@@ -51,11 +50,10 @@ If you want to upload multiple images (let us say we have multiple atlases), use
5150
5251
And this will iteratively upload all instances of the atlas to OSF.
5352

54-
Step 2: Telling Datalad where the files are
55-
================================================
56-
57-
Github is using Datalad to track the files.
58-
You need to tell Datalad where the new files are.
53+
Step 2: Telling DataLad where the files are
54+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55+
Github is using DataLad to track the files.
56+
You need to tell DataLad where the new files are.
5957

6058
To do this, run the following python script, changing the tqo required variables:
6159

@@ -123,8 +121,8 @@ Then you add the new urls to DataLad. Add a message
123121
datalad addurls new_files.csv '{link}' '{name}' --message 'My test atlases'
124122
datalad publish
125123
126-
Example script when subdirectories are presents
127-
================================================
124+
Example script when subdirectories are present
125+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128126

129127
.. code-block:: python
130128
@@ -167,4 +165,4 @@ Example script when subdirectories are presents
167165
link = subitem['links']['download']
168166
path = subitem['attributes']['materialized']
169167
hits.append(','.join((name, link)))
170-
Path(output_filename).write_text('\n'.join(hits))
168+
Path(output_filename).write_text('\n'.join(hits))

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Contents
99
.. toctree::
1010
:maxdepth: 3
1111

12+
naming
13+
tutorials
1214
api/templateflow
1315

1416
What's new

docs/templateflow_naming.rst renamed to docs/naming.rst

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11

22
TemplateFlow Naming
3-
===========================
3+
===================
44

5-
Who is this tutorial for?
6-
=================================
5+
.. admonition :: Who is this tutorial for?
76
8-
Anyone trying to understand the naming structure in TemplateFlow.
7+
Anyone trying to understand the naming structure in TemplateFlow.
98
109
Naming information
11-
===========================
12-
13-
TemplateFlow generally follows the `BIDS naming structure <https://bids-specification.readthedocs.io/en/derivatives/>`_, but has a few deviations (e.g. the tpl key).
10+
~~~~~~~~~~~~~~~~~~
11+
TemplateFlow generally follows the `BIDS naming structure <https://bids-specification.readthedocs.io/en/derivatives/>`__, but has a few deviations (e.g. the ``tpl`` key).
1412
Here we outline the most common names that are found in TemplateFlow.
1513

1614
Common key names using in TemplateFlow:
@@ -48,10 +46,7 @@ Extension Description
4846
.h5 Transform file
4947
========== =======
5048

51-
Thus a template with the following name:
52-
53-
``tpl-test_res-01_atlas-myatlas_desc-200nodes_dseg.nii.gz``
54-
55-
This would be a nifti image containing discrete segmentation of "myatlas" which contains 200nodes.
56-
And it is in the template space "test".
49+
Thus a template with the following name: ``tpl-test_res-01_atlas-myatlas_desc-200nodes_dseg.nii.gz``
50+
would be a NIfTI image containing discrete segmentation of "myatlas" which contains 200nodes.
51+
And it is in the template space "test".
5752
The resolution information will be found in the dataset_description.json file under '01'.

docs/tutorials.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. include:: links.rst
2+
3+
Publishing in TemplateFlow
4+
==========================
5+
Tutorials demonstrating how to upload new template resources to
6+
TemplateFlow.
7+
8+
.. toctree::
9+
:glob:
10+
:maxdepth: 3
11+
12+
contributing_tutorials/prerequisites_to_contributing
13+
contributing_tutorials/adding_a_new_template
14+
contributing_tutorials/uploading_to_existing_template

0 commit comments

Comments
 (0)