Skip to content

Commit

Permalink
Merge pull request #85 from neuropoly/rb/subjects_file
Browse files Browse the repository at this point in the history
Creation of `subjects.csv` in the correct path and fixing minor bugs in the path name
  • Loading branch information
rohanbanerjee authored Nov 9, 2023
2 parents dee67cf + ca1c557 commit 8044349
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,22 @@ e) Minc2simple
```
pip install "git+https://github.com/NIST-MNI/minc2-simple.git@develop_new_build#subdirectory=python"
```
f) Update the absolute of the `subjects.csv` in the `generate_template.py` script. The `subjects.csv` lies inside the `DATASET/derivatives/template` directory

f) Create `template_pipleline.sh`
g) Create `template_pipleline.sh`
> **Note:**
> Create the `template_pipeline.sh` inside the `template` folder.
```
#!/bin/bash
python -m scoop -vvv generate_template.py
```

g) Batch on Alliance Canada
h) Batch on Alliance Canada
```
sbatch --time=24:00:00 --mem-per-cpu 4000 template_pipeline.sh # will probably require batching several times, depending on number of subjects
```

h) Final output
i) Final output
<p>After the pipeline has finished running, the `.mnc` file needs to be converted to `.nii` format in order to get the final template. The pipeline would give outputs with the name: avg.XXX.mnc, where `XXX` is the nth iteration. To convert it to the `.nii` format, run the following command:</p>

```
Expand Down
6 changes: 3 additions & 3 deletions preprocess_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,15 +639,15 @@ def create_mask_template(dataset_info):
if os.path.isfile(path_template + '/template_mask.mnc'): os.remove(path_template + '/template_mask.mnc')

os.system('nii2mnc ' + path_template + '/template_mask.nii.gz ' + ' ' + path_template + '/template_mask.mnc')
return path_template + '/template_mask.mnc'
return path_template + 'template_mask.mnc'

def convert_data2mnc(dataset_info):
path_template = dataset_info['path_data'] + 'derivatives/template/'
list_subjects = dataset_info['include_list'].split(' ')

path_template_mask = create_mask_template(dataset_info)

output_list = open('subjects.csv', "w")
output_list = open(path_template + 'subjects.csv', "w")
writer = csv.writer(output_list, delimiter = ',', quotechar = ',', quoting = csv.QUOTE_MINIMAL)

tqdm_bar = tqdm(total = len(list_subjects), unit = 'B', unit_scale = True, desc = "Status", ascii = True)
Expand All @@ -661,7 +661,7 @@ def convert_data2mnc(dataset_info):
os.system('nii2mnc ' + fname_nii + ' ' + fname_mnc)
os.remove(fname_nii) # remove duplicate nifti file!

writer.writerow([fname_mnc,path_template_mask])
writer.writerow([fname_mnc, path_template_mask])

tqdm_bar.update(1)
tqdm_bar.close()
Expand Down

0 comments on commit 8044349

Please sign in to comment.