2
2
from tempfile import TemporaryDirectory
3
3
from pathlib import Path
4
4
from os .path import join
5
- import pprint
6
5
import shutil
7
6
import subprocess
8
7
import bids
@@ -190,28 +189,26 @@ def download_test_data(
190
189
if meta .get ("subject_ids" , []) != []:
191
190
for id in meta ["subject_ids" ]:
192
191
combined_subjects .append (id )
193
- # Instead of using pybids, get all files in the subject directory
194
- all_files = []
192
+ # Get the entire subject directory content including git-annex files
195
193
subject_dir = dataset_path / f"sub-{ id } "
196
194
if subject_dir .exists ():
197
- # Get all files in the subject directory recursively
195
+ # First, get all content in the subject directory (this retrieves git-annex files)
196
+ result = dataset .get (str (subject_dir ))
197
+
198
+ # Then collect all files after they've been retrieved
198
199
all_files = []
199
200
for file_path in subject_dir .rglob ("*" ):
200
201
if file_path .is_file ():
201
202
relative_path = file_path .relative_to (dataset_path )
202
203
all_files .append (str (relative_path ))
203
- for f in all_files :
204
- print (f )
205
- # Get the file relative to the dataset path
206
- result = dataset .get (dataset_path / f )
207
- if (
208
- result [0 ].get ("status" ) == "ok"
209
- or result [0 ].get ("message" ) == "already present"
210
- ):
211
- # Then unlock it to make it writable
204
+
205
+ # Copy all files to output directory
206
+ for f in all_files :
207
+ print (f )
208
+ # Unlock the file to make it writable
212
209
api .unlock (
213
210
path = str (dataset_path / f ), dataset = str (dataset_path )
214
- )
211
+ )
215
212
source_file = dataset_path / f
216
213
relative_path = source_file .relative_to (dataset_path )
217
214
target_file = Path (output_directory ) / relative_path
@@ -232,8 +229,6 @@ def download_test_data(
232
229
combined_participants_tsv ["participant_id" ].isin (combined_subjects )
233
230
]
234
231
235
- print (combined_participants )
236
-
237
232
# Only write files if a specific download path was provided
238
233
dataset_desc_path = Path (output_directory ) / "dataset_description.json"
239
234
readme_path = Path (output_directory ) / "README.md"
0 commit comments