1
1
.. _data-package-design :
2
2
3
- Design of data packages for the nipy suite
4
- ==========================================
3
+ Design of data packages for the nibabel and the nipy suite
4
+ ==========================================================
5
5
6
6
See :ref: `data-package-discuss ` for a more general discussion of design
7
7
issues.
@@ -17,7 +17,8 @@ data files nipy uses into at least 3 categories
17
17
Files used for routine testing are typically very small data files. They are
18
18
shipped with the software, and live in the code repository. For example, in
19
19
the case of ``nipy `` itself, there are some test files that live in the module
20
- path ``nipy.testing.data ``.
20
+ path ``nipy.testing.data ``. Nibabel ships data files in
21
+ ``nibabel.tests.data ``. See :doc: `add_test_data ` for discussion.
21
22
22
23
*template data * and *example data * are example of *data packages *. What
23
24
follows is a discussion of the design and use of data packages.
@@ -45,7 +46,7 @@ Use cases for data packages
45
46
Using the data package
46
47
``````````````````````
47
48
48
- The programmer will want to use the data something like this:
49
+ The programmer can use the data like this:
49
50
50
51
.. testcode ::
51
52
@@ -78,9 +79,9 @@ found, and how it should be installed.
78
79
Warnings during installation
79
80
````````````````````````````
80
81
81
- The example data and template data may be important, and it would be
82
- useful to warn the user if NIPY cannot find either of the two sets of
83
- data when installing the package. Thus::
82
+ The example data and template data may be important, and so we want to warn
83
+ the user if NIPY cannot find either of the two sets of data when installing
84
+ the package. Thus::
84
85
85
86
python setup.py install
86
87
@@ -98,23 +99,22 @@ install the data.
98
99
Finding the data
99
100
````````````````
100
101
101
- The routine ``make_datasource `` will need to be able to find the data
102
- that has been installed. For the following call:
102
+ The routine ``make_datasource `` will look for data packages that have been
103
+ installed. For the following call:
103
104
104
105
>>> templates = make_datasource(dict (relpath = ' nipy/templates' ))
105
106
106
- We propose to :
107
+ the code will :
107
108
108
109
#. Get a list of paths where data is known to be stored with
109
- ``nipy .data.get_data_path() ``
110
+ ``nibabel .data.get_data_path() ``
110
111
#. For each of these paths, search for directory ``nipy/templates ``. If
111
112
found, and of the correct format (see below), return a datasource,
112
113
otherwise raise an Exception
113
114
114
- The paths collected by ``nipy.data.get_data_paths() `` will be
115
- constructed from ':' (Unix) or ';' separated strings. The source of the
116
- strings (in the order in which they will be used in the search above)
117
- are:
115
+ The paths collected by ``nibabel.data.get_data_paths() `` are constructed from
116
+ ':' (Unix) or ';' separated strings. The source of the strings (in the order
117
+ in which they will be used in the search above) are:
118
118
119
119
#. The value of the ``NIPY_DATA_PATH `` environment variable, if set
120
120
#. A section = ``DATA ``, parameter = ``path `` entry in a
126
126
``/etc/nipy `` on Unix, and some suitable equivalent on Windows.
127
127
#. The result of ``os.path.join(sys.prefix, 'share', 'nipy') ``
128
128
#. If ``sys.prefix `` is ``/usr ``, we add ``/usr/local/share/nipy ``. We
129
- need this because Python 2.6 in Debian / Ubuntu does default installs
130
- to ``/usr/local ``.
129
+ need this because Python >= 2.6 in Debian / Ubuntu does default installs to
130
+ ``/usr/local ``.
131
131
#. The result of ``get_nipy_user_dir() ``
132
132
133
133
Requirements for a data package
@@ -175,7 +175,7 @@ packages have been installed::
175
175
`-- config.ini
176
176
177
177
The ``<ROOT> `` directory is the directory that will appear somewhere in
178
- the list from ``nipy .data.get_data_path() ``. The ``nipy `` subdirectory
178
+ the list from ``nibabel .data.get_data_path() ``. The ``nipy `` subdirectory
179
179
signifies data for the ``nipy `` package (as opposed to other
180
180
NIPY-related packages such as ``pbrain ``). The ``data `` subdirectory of
181
181
``nipy `` contains files from the ``nipy-data `` package. In the
@@ -192,9 +192,8 @@ giving the version of the data package.
192
192
Installing the data
193
193
```````````````````
194
194
195
- We will use python distutils to install data packages, and the
196
- ``data_files `` mechanism to install the data. On Unix, with the
197
- following command::
195
+ We use python distutils to install data packages, and the ``data_files ``
196
+ mechanism to install the data. On Unix, with the following command::
198
197
199
198
python setup.py install --prefix=/my/prefix
200
199
@@ -211,8 +210,8 @@ because ``nipy`` is both the project, and the package to which the data
211
210
relates.
212
211
213
212
If you install to a particular location, you will need to add that location to
214
- the output of ``nipy .data.get_data_path() `` using one of the mechanisms above,
215
- for example, in your system configuration::
213
+ the output of ``nibabel .data.get_data_path() `` using one of the mechanisms
214
+ above, for example, in your system configuration::
216
215
217
216
export NIPY_DATA_PATH=/my/prefix/share/nipy
218
217
0 commit comments