Skip to content

Commit c02a68f

Browse files
authored
Rename histology to anat and move to session level. (#229)
* Update all tests to remove use_datatype flag. * Fix documentation. * Update all tests to remove use_datatype flag. * Rename histology to anat. * Change position of anat. * Fix tests. * Fix documentation. * Fix documentation. * Fix linting after rebase. * Fix documentation again.
1 parent e2b6fb7 commit c02a68f

File tree

12 files changed

+78
-116
lines changed

12 files changed

+78
-116
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,32 @@ See the SWC-BIDS [specification](https://swc-bids.neuroinformatics.dev/) for mor
3636
└── raw_data/
3737
├── sub-001/
3838
│ └── ses-001/
39-
├── ephys/
40-
└── behav/
41-
│ └── histology/
39+
├── ephys/
40+
└── behav/
41+
└── anat/
4242
└── sub-002/
4343
└── ses-001/
4444
│ ├── behav/
4545
│ └── imaging/
4646
└── ses-002/
47-
└── behav/
48-
└── histology/
47+
└── behav/
48+
└── anat/
4949
```
5050

5151

5252
```+
5353
└── project_name/
54-
└── rawdata/
54+
└── rawdata/[test_utils.py](tests%2Ftest_utils.py)
5555
├── sub-001 /
56-
── ses-001/
57-
├── ephys
58-
└── behav
59-
│ └── histology
56+
── ses-001/
57+
├── ephys
58+
└── behav
59+
└── anat
6060
└── sub-002/
6161
├── ses-001/
6262
│ ├── behav
6363
│ └── imaging
64-
── ses-002/
65-
└── behav
66-
└── histology
64+
── ses-002/
65+
└── behav
66+
└── anat
6767
```

datashuttle/configs/canonical_configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_datatypes() -> List[str]:
4646
Canonical list of datatype flags based on
4747
NeuroBlueprint.
4848
"""
49-
return ["ephys", "behav", "funcimg", "histology"]
49+
return ["ephys", "behav", "funcimg", "anat"]
5050

5151

5252
def get_flags() -> List[str]:

datashuttle/configs/canonical_folders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ def get_datatype_folders(cfg: Configs) -> dict:
5151
name="funcimg",
5252
level="ses",
5353
),
54-
"histology": Folder(
55-
name="histology",
56-
level="sub",
54+
"anat": Folder(
55+
name="anat",
56+
level="ses",
5757
),
5858
}
5959

datashuttle/datashuttle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def make_folders(
180180
folders are made.
181181
datatype :
182182
The datatype to make in the sub / ses folders.
183-
(e.g. "ephys", "behav", "histology"). If "all"
183+
(e.g. "ephys", "behav", "anat"). If "all"
184184
is selected, all datatypes permitted in
185185
NeuroBlueprint will be created. If "" is passed
186186
no datatype will be created.

docs/source/pages/documentation.md

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ ssh \
9393
--overwrite_old_files
9494
```
9595

96-
9796
Now setup is complete! _Configuration_ settings can be edited at any time with the `update-config` command. Alternatively, custom *configuration* files can be supplied using the `supply-config` command (this simplifies setting up projects across multiple *local* machines).
9897

9998
Next, we can start setting up the project by automatically creating standardised project folder trees.
@@ -132,33 +131,31 @@ Another example call, which creates a range of subject and session folders, is s
132131
```
133132
datashuttle \
134133
my_first_project \
134+
make-folders -sub 001@TO@003 -ses 010_@TIME@ -dt behav funcimg anat
135+
```
135136

136-
make-sub-folders -sub 001@TO@003 -ses 010_@TIME@ -dt behav funcimg histology
137137

138138
```
139139
├── sub-001/
140-
── ses-010_time-160248/
141-
├── behav
142-
└── funcimg
143-
│ └── histology
140+
── ses-010_time-160248/
141+
├── behav
142+
└── funcimg
143+
└── anat
144144
├── sub-002/
145-
── ses-010_time-160248/
146-
── behav
147-
└── funcimg
148-
│ └── histology
145+
── ses-010_time-160248/
146+
── behav
147+
└── funcimg
148+
└── anat
149149
└── sub-003/
150-
── ses-010_time-160248/
151-
├── behav
152-
── funcimg
153-
└── histology
150+
── ses-010_time-160248/
151+
├── behav
152+
── funcimg
153+
└── anat
154154
```
155155

156-
157156
### Datatype Folders
158157

159-
In [SWC-Blueprint](https://swc-blueprint.neuroinformatics.dev/specification.html), *datatypes* specify where acquired experimental data of currently supported types (`behav`, `ephys`, `funcimg` and `histology`) is stored. See the [*datatypes* section of the SWC-Blueprint for more details](https://swc-blueprint.neuroinformatics.dev/specification.html#datatype).
160-
161-
At present, `histology` is saved to the `sub-` level, as it is assumed `histology` is conducted *ex vivo* and so session will be possible. Please don't hesitate to get into contact if you have an alternative use case.
158+
In [SWC-Blueprint](https://swc-blueprint.neuroinformatics.dev/specification.html), *datatypes* specify where acquired experimental data of currently supported types (`behav`, `ephys`, `funcimg` and `anat`) is stored. See the [*datatypes* section of the SWC-Blueprint for more details](https://swc-blueprint.neuroinformatics.dev/specification.html#datatype).
162159

163160
## Data Transfer
164161

@@ -498,15 +495,15 @@ DataShuttle provides a number of keyword arguments to allow separate handling of
498495

499496
`all` : All *session* and non-*session* files and folders within a *subject* level folder (e.g. `sub-001`) will be transferred.
500497

501-
`all_ses` : *Session* <u>folders</u> only (i.e. prefixed with `-ses`) will be transferred. Note that the only exception is the `histology` folder, the transfer of which is determined by the `-dt` flag (below).
498+
`all_ses` : *Session* <u>folders</u> only (i.e. prefixed with `-ses`) will be transferred.
502499

503500
`all_non_ses` : All files and folders that are not prefixed with `-sub` will be transferred. Any folders prefixed with `-ses` will not be transferred.
504501

505502
#### For use with the `-dt` / `--datatype` flag
506503

507504
`all` : All *datatype* folders at the *subject* or *session* folder level will be transferred, as well as all files and folders within selected *session* folders.
508505

509-
`all_datatype` : All *datatype* folders (i.e. folders with the pre-determined name: `behav`, `ephys`, `funcimg`, `histology`) residing at either the *subject* or *session* level will be
506+
`all_datatype` : All *datatype* folders (i.e. folders with the pre-determined name: `behav`, `ephys`, `funcimg`, `anat`) residing at the *session* level will be
510507
transferred. Non-*datatype* folders at the *session* level will not be transferred
511508

512509
`all_ses_level_non_datatype` : Non *datatype* folders at the *session* level will not be transferred
@@ -519,7 +516,6 @@ Below, a number of examples are given to exemplify how these arguments effect da
519516
├── a_project_related_file.json
520517
├── sub-001/
521518
│ ├── sub-001_extra-file.json
522-
│ ├── histology
523519
│ └── ses-001/
524520
│ ├── ses-001_extra-file.json
525521
│ ├── behav/
@@ -528,7 +524,6 @@ Below, a number of examples are given to exemplify how these arguments effect da
528524
│ └── ...
529525
└── sub-002/
530526
├── sub-002_extra-file.json
531-
├── histology
532527
└── ses-001/
533528
├── behav/
534529
│ └── ...
@@ -569,7 +564,7 @@ Would upload:
569564

570565
- Contents residing in the `sub-001` folder only.
571566
- The file `sub-001_extra-file.json`
572-
- All *datatype* folder contents (`histology`, `behav`, `ephys`)
567+
- All *datatype* folder contents (`anat`, `behav`, `ephys`)
573568

574569
The command:
575570

@@ -585,7 +580,7 @@ upload
585580
Would upload:
586581

587582
- Contents residing in the `sub-001` folder only.
588-
- All *datatype* folder contents (`histology`, `behav`, `ephys`)
583+
- All *datatype* folder contents (`anat`, `behav`, `ephys`)
589584

590585
3) The final example shows the effect of transferring `all_non_sub` files only. The command:
591586

tests/test_utils.py

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def check_datatype_sub_ses_uploaded_correctly(
321321
sub_names = glob_basenames(join(base_path_to_check, "*"))
322322
assert sub_names == sorted(subs_to_upload)
323323

324-
# Check ses are all uploaded + histology if transferred
324+
# Check ses are all uploaded
325325
if ses_to_upload:
326326
for sub in subs_to_upload:
327327
ses_names = glob_basenames(
@@ -331,42 +331,15 @@ def check_datatype_sub_ses_uploaded_correctly(
331331
"*",
332332
)
333333
)
334-
if datatype_to_transfer == ["histology"]:
335-
assert ses_names == ["histology"]
336-
return # handle the case in which histology
337-
# only is transferred,
338-
# and there are no sessions to transfer.
339-
340-
copy_datatype_to_transfer = (
341-
check_and_strip_within_sub_data_folders(
342-
ses_names, datatype_to_transfer
343-
)
344-
)
345334
assert ses_names == sorted(ses_to_upload)
346335

347336
# check datatype folders in session folder
348-
if copy_datatype_to_transfer:
337+
if datatype_to_transfer:
349338
for ses in ses_names:
350339
data_names = glob_basenames(
351340
join(base_path_to_check, sub, ses, "*")
352341
)
353-
assert data_names == sorted(copy_datatype_to_transfer)
354-
355-
356-
def check_and_strip_within_sub_data_folders(ses_names, datatype_to_transfer):
357-
"""
358-
Check if datatype folders at the sub level are picked
359-
up when sessions are searched for with wildcard. Remove
360-
so that sessions can be explicitly tested next.
361-
"""
362-
if "histology" in datatype_to_transfer:
363-
assert "histology" in ses_names
364-
365-
ses_names.remove("histology")
366-
copy_ = copy.deepcopy(datatype_to_transfer)
367-
copy_.remove("histology")
368-
return copy_
369-
return datatype_to_transfer
342+
assert data_names == sorted(datatype_to_transfer)
370343

371344

372345
def make_and_check_local_project_folders(

tests/tests_integration/file_conflicts_pathtable.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ def get_pathtable(base_folder):
1616
[base_folder, Path("rawdata") / "sub-001" / "ses-003_date-20231901" / "behav" / "behav.csv", False, False, False, "sub-001", "ses-003_date-20231901", "behav"],
1717
[base_folder, Path("rawdata") / "sub-001" / "ses-003_date-20231901" / "ephys" / "ephys.bin", False, False, False, "sub-001", "ses-003_date-20231901", "ephys"],
1818
[base_folder, Path("rawdata") / "sub-001" / "ses-003_date-20231901" / "non_data" / "non_data.mp4", False, False, True, "sub-001", "ses-003_date-20231901", None],
19-
[base_folder, Path("rawdata") / "sub-001" / "ses-003_date-20231901" / "nondatatype_level_file.csv", False, False, True, "sub-001", "ses-003_date-20231901", None],
19+
[base_folder, Path("rawdata") / "sub-001" / "ses-003_date-20231901" / "nondatatype_level_file.csv", False, False, True, "sub-001", "ses-003_date-20231901", None],
2020
[base_folder, Path("rawdata") / "sub-001" / "random-ses_level_file.mp4", False, True, False, "sub-001", None, None],
21-
[base_folder, Path("rawdata") / "sub-001" / "histology" / "sub-001_histology.file", False, False, False, "sub-001", None, "histology"],
21+
[base_folder, Path("rawdata") / "sub-001" / "ses-004" / "anat" / "sub-001_anat.file", False, False, False, "sub-001", "ses-004", "anat"],
2222
[base_folder, Path("rawdata") / "sub-002_random-value" / "sub-002_random-value.file", False, True, False, "sub-002_random-value", None, None],
23-
[base_folder, Path("rawdata") / "sub-002_random-value" / "ses-001" / "non_datatype_level_folder" / "file.csv", False, False, True, "sub-002_random-value", "ses-001", None],
23+
[base_folder, Path("rawdata") / "sub-002_random-value" / "ses-001" / "non_datatype_level_folder" / "file.csv", False, False, True, "sub-002_random-value", "ses-001", None],
2424
[base_folder, Path("rawdata") / "sub-003_date-20231901" / "ses-001" / "funcimg" / ".myfile.xlsx", False, False, False, "sub-003_date-20231901", "ses-001", "funcimg"],
25-
[base_folder, Path("rawdata") / "sub-003_date-20231901" / "ses-003_date-20231901" / "nondatatype_level_file.csv", False, False, True, "sub-003_date-20231901", "ses-003_date-20231901", None],
25+
[base_folder, Path("rawdata") / "sub-003_date-20231901" / "ses-003_date-20231901" / "nondatatype_level_file.csv", False, False, True, "sub-003_date-20231901", "ses-003_date-20231901", None],
2626
[base_folder, Path("rawdata") / "sub-003_date-20231901" / "ses-003_date-20231901" / "funcimg" / "funcimg.nii", False, False, False, "sub-003_date-20231901", "ses-003_date-20231901", "funcimg"],
27-
[base_folder, Path("rawdata") / "sub-003_date-20231901" / "seslevel_non-prefix_folder" / "nonlevel.mat", False, True, False, "sub-003_date-20231901", "seslevel_non-prefix_folder", None],
27+
[base_folder, Path("rawdata") / "sub-003_date-20231901" / "seslevel_non-prefix_folder" / "nonlevel.mat", False, True, False, "sub-003_date-20231901", "seslevel_non-prefix_folder", None],
2828
[base_folder, Path("rawdata") / "sub-003_date-20231901" / "sub-ses-level_file.txt", False, True, False, "sub-003_date-20231901", None, None],
29-
[base_folder, Path("rawdata") / "sub-003_date-20231901" / "histology" / ".histology.file", False, False, False, "sub-003_date-20231901", None, "histology"],
29+
[base_folder, Path("rawdata") / "sub-003_date-20231901" / "ses-004" / "anat" / ".anat.file", False, False, False, "sub-003_date-20231901", "ses-004", "anat"],
3030
[base_folder, Path("rawdata") / "project_level_file.txt", True, False, False, None, None, None],
31-
[base_folder, Path("rawdata") / "sublevel_non_sub-prefix_folder" / "ses_non_folder.file", True, False, False, None, None, None],
31+
[base_folder, Path("rawdata") / "sublevel_non_sub-prefix_folder" / "ses_non_folder.file", True, False, False, None, None, None],
3232
]
3333

3434

tests/tests_integration/test_configs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ def test_supplied_config_file_changes_wrong_order(self, project, tmp_path):
332332
any order and just converted to dict?
333333
"""
334334
bad_order_configs_path = project._datashuttle_path / "new_configs.yaml"
335+
335336
good_order_configs = test_utils.get_test_config_arguments_dict(
336337
tmp_path, project.project_name
337338
)

tests/tests_integration/test_filesystem_transfer.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ def test_transfer_all_top_level_folders(self, project, upload_or_download):
137137
["behav"],
138138
["ephys"],
139139
["funcimg"],
140-
["histology"],
140+
["anat"],
141141
["behav", "ephys"],
142-
["ephys", "histology"],
143-
["behav", "ephys", "histology"],
144-
["funcimg", "histology", "behav"],
145-
["behav", "ephys", "funcimg", "histology"],
142+
["ephys", "anat"],
143+
["behav", "ephys", "anat"],
144+
["funcimg", "anat", "behav"],
145+
["behav", "ephys", "funcimg", "anat"],
146146
],
147147
)
148148
@pytest.mark.parametrize("upload_or_download", ["upload", "download"])
@@ -179,10 +179,10 @@ def test_transfer_empty_folder_specific_dataal_data(
179179
@pytest.mark.parametrize(
180180
"datatype_to_transfer",
181181
[
182-
["histology"],
182+
["anat"],
183183
["behav", "ephys"],
184-
["funcimg", "histology", "behav"],
185-
["behav", "ephys", "funcimg", "histology"],
184+
["funcimg", "anat", "behav"],
185+
["behav", "ephys", "funcimg", "anat"],
186186
],
187187
)
188188
@pytest.mark.parametrize("upload_or_download", ["upload" "download"])
@@ -223,7 +223,7 @@ def test_transfer_empty_folder_specific_subs(
223223
@pytest.mark.parametrize("sub_idx_to_upload", [[0], [1, 2], [0, 1, 2]])
224224
@pytest.mark.parametrize(
225225
"datatype_to_transfer",
226-
[["ephys"], ["funcimg", "histology", "behav"]],
226+
[["ephys"], ["funcimg", "anat", "behav"]],
227227
)
228228
@pytest.mark.parametrize("upload_or_download", ["upload", "download"])
229229
def test_transfer_empty_folder_specific_ses(
@@ -429,10 +429,10 @@ def test_rclone_overwrite_modified_file(
429429
the version in source is newer than target.
430430
"""
431431
path_to_test_file = (
432-
Path("rawdata") / "sub-001" / "histology" / "test_file.txt"
432+
Path("rawdata") / "sub-001" / "ses-001" / "anat" / "test_file.txt"
433433
)
434434

435-
project.make_folders("sub-001", datatype="histology")
435+
project.make_folders("sub-001", "ses-001", datatype="anat")
436436

437437
local_test_file_path = project.cfg["local_path"] / path_to_test_file
438438
central_test_file_path = (

tests/tests_integration/test_logging.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,9 @@ def test_logs_upload_and_download(
271271

272272
assert "Using config file from" in log
273273
assert "Local file system at" in log
274-
assert """ "--include" "sub-11/histology/**" """ in log
275-
assert """/central/test_project/rawdata""" in log
274+
assert "--include" in log
275+
assert "sub-11/ses-123/anat/**" in log
276+
assert "/central/test_project/rawdata" in log
276277
assert "Waiting for checks to finish" in log
277278

278279
@pytest.mark.parametrize("upload_or_download", ["upload", "download"])

0 commit comments

Comments
 (0)