Comments (17)
It seems to me that it couldn't find any files (that's why num_files was not assigned). Coincidentally, I fixed this the other day in my (unreleased) development version. So the file structure in your test-folder is not what was expected by bidsmapper.py, can you give a tree-view?
from bidscoin.
I've also been running into the same error with my subject. Here's the tree-view:
.
|-sub-1036
|---001-anat-scout_acq-localizer
|---002-anat_T1w
|---003-anat_T1w
|---004-fmap_run-01
|---005-fmap_run-02
|---006-func_task-std_run-01_SBRef
|---007-func_task-std_run-01
|---008-func_task-std_run-02_SBRef
|---009-func_task-std_run-02
|---010-func_task-std_run-03_SBRef
|---011-func_task-std_run-03
|---012-func_task-std_run-04_SBRef
|---013-func_task-std_run-04
|---014-func_task-std_run-05_SBRef
|---015-func_task-std_run-05
|---016-func_task-std_run-06_SBRef
|---017-func_task-std_run-06
|---018-func_task-std_run-07_SBRef
|---019-func_task-std_run-07
|---020-func_task-std_run-08_SBRef
|---021-func_task-std_run-08
|---022-anat_T2w
from bidscoin.
The tree looks fine, so perhaps the dicom files in the series folders are not recognized? Can you perhaps show me (a snippet of) the content of e.g. 002-anat_T1w
?
from bidscoin.
The dicoms in that folder look like this:
001_000002_000001.dcm
001_000002_000002.dcm
001_000002_000003.dcm
....
001_000002_000208.dcm
These have come from a Siemens Prisma scanner, and there are only dicom files in the series folders.
from bidscoin.
I need more info to replicate this. I did this:
conda create -n bidscointest python==3.6
[..]
source activate bidscointest
pip install bidscoin
[..]
And I get:
(bidscointest) mentat005/tmp$ tree test
test
`-- sub-1036
`-- 002-anat_T1w
|-- 00002_1.3.12.2.1107.5.2.19.45416.2017121915051526005675150.dcm
|-- 00003_1.3.12.2.1107.5.2.19.45416.2017121915051520026075138.dcm
|-- 00004_1.3.12.2.1107.5.2.19.45416.2017121915051515689275130.dcm
|-- 00005_1.3.12.2.1107.5.2.19.45416.2017121915051518607275136.dcm
[..]
(bidscointest) mentat005/tmp$ bidsmapper.py test bidstest
2019-11-20 18:38:15 - bidscoin - INFO
2019-11-20 18:38:15 - bidscoin - INFO -------------- START BIDSmapper ------------
2019-11-20 18:38:15 - bidscoin - INFO No bidsmap file found: /home/mrphys/marzwi/.conda/envs/bidscointest/lib/python3.6/site-packages/heuristics/bidsmap.yaml
2019-11-20 18:38:15 - bidscoin - INFO Reading: /home/mrphys/marzwi/.conda/envs/bidscointest/lib/python3.6/site-packages/heuristics/bidsmap_template.yaml
2019-11-20 18:38:15 - bidscoin - INFO Parsing: /home/mrphys/marzwi/tmp/test/sub-1036 (subject 1/1)
2019-11-20 18:38:15 - bidscoin - INFO New 'extra_data' sample found: /home/mrphys/marzwi/tmp/test/sub-1036/002-anat_T1w/00002_1.3.12.2.1107.5.2.19.45416.2017121915051526005675150.dcm
2019-11-20 18:38:15 - bidscoin - INFO Writing bidsmap to: /home/mrphys/marzwi/tmp/bidstest/code/bidscoin/bidsmap.yaml
2019-11-20 18:38:18 - bidscoin - INFO Opening the bidseditor
2019-11-20 18:38:21 - bidscoin - INFO -------------- FINISHED! -------------------
2019-11-20 18:38:21 - bidscoin - INFO
2019-11-20 18:38:21 - bidscoin - INFO No BIDScoin errors or warnings were reported
2019-11-20 18:38:21 - bidscoin - INFO
2019-11-20 18:38:21 - bidscoin - INFO For the complete log see: /home/mrphys/marzwi/tmp/bidstest/code/bidscoin/bidsmapper.log
2019-11-20 18:38:21 - bidscoin - INFO NB: logfiles may contain identifiable information, e.g. from pathnames
from bidscoin.
Would it be possible to send me just 1 dicomfile (e.g. from the bottom slice, i.e. containing no identifiable data)? It seems to me that the dicomfiles are somehow not recognized as a dicomfiles. You can also test this yourself as follows:
(bidscointest) mentat005/~$ python
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from bidscoin import bids
>>> bids.is_dicomfile('tmp/test/sub-1036/002-anat_T1w/00002_1.3.12.2.1107.5.2.19.45416.2017121915051526005675150.dcm')
True
from bidscoin.
Thank you @dlevitas for sending me the dicomfile. It all works fine here, so I guess there must be a problem with the path to your source-data folder:
usage: bidsmapper.py [-h] [-b BIDSMAP] [-t TEMPLATE] [-n SUBPREFIX]
[-m SESPREFIX] [-i {0,1,2}] [-v]
sourcefolder bidsfolder
Can you give me the exact command that you used?
from bidscoin.
Hi @marcelzwiers,
Here are the steps I took to get where I'm currently at. The dicom directory initially contains all the dicoms together, unseparated by series number. Due to this, I ran dicomsort using the following command
dicomsort.py $dicom_dir
which properly organizes the dicoms by their series number.
Next, I ran bidsmapper as follows:
bidsmapper.py $dicom_dir $testing_dir/bidscoin_testing
which produces the error that @soichih raised initially.
I can avoid this issue by specifying the --interactive 0
option, which produces this output:
2019-11-21 09:07:19 - bidscoin - INFO
2019-11-21 09:07:19 - bidscoin - INFO -------------- START BIDSmapper ------------
2019-11-21 09:07:19 - bidscoin - INFO Reading: /media/data/dlevitas/sample_data/bidscoin_testing/code/bidscoin/bidsmap.yaml
2019-11-21 09:07:19 - bidscoin - INFO Reading: /usr/local/lib/python3.6/dist-packages/heuristics/bidsmap_template.yaml
2019-11-21 09:07:19 - bidscoin - INFO Writing bidsmap to: /media/data/dlevitas/sample_data/bidscoin_testing/code/bidscoin/bidsmap.yaml
2019-11-21 09:07:20 - bidscoin - INFO -------------- FINISHED! -------------------
2019-11-21 09:07:20 - bidscoin - INFO
2019-11-21 09:07:20 - bidscoin - INFO No BIDScoin errors or warnings were reported
2019-11-21 09:07:20 - bidscoin - INFO
2019-11-21 09:07:20 - bidscoin - INFO For the complete log see: /media/data/dlevitas/sample_data/bidscoin_testing/code/bidscoin/bidsmapper.log
2019-11-21 09:07:20 - bidscoin - INFO NB: logfiles may contain identifiable information, e.g. from pathnames
However, the generated bidsmap.yaml does not contain any pertinent information. This is where we are currently running into problems. For reference, we are using python 3.6.8
from bidscoin.
I still think there is an issue with the path of your sourcefolder. The problem is that the logger statement is never reached in these lines of bidsmapper code:
# Loop over all subjects and sessions and built up the bidsmap entries
subjects = bids.lsdirs(rawfolder, subprefix + '*')
for n, subject in enumerate(subjects,1):
sessions = bids.lsdirs(subject, sesprefix + '*')
if not sessions: sessions = [subject]
for session in sessions:
LOGGER.info(f'Parsing: {session} (subject {n}/{len(subjects)})')
So the sub-#
folders must be located directly under your $dicom_dir
folder. It seems to me that running ls $dicom_dir/sub-*
in a bash shell would give an empty result?
from bidscoin.
Ah yes, I was incorrectly setting the sourcefolder to the subfolder with the series numbers. I'm now able to work with the bidseditor.
Thanks for the assistance.
from bidscoin.
@soichih Is your problem fixed also? Then I can close this issue
from bidscoin.
I tried to run bidsmapper.py on one of our sample directory structure, and I couldn't get it to work.
So, the directory structure must include /ses-.. to organize it under each session?
My test directory structure looks like this.
$ ls
list mr_0004 mr_0005 mr_0006 mr_0007 raw.list README-Study.txt
$ ls *
list raw.list README-Study.txt
mr_0004:
20180918114023.json axial_epi_fmri_interleaved_i_to_s-00050.dcm axial_epi_fmri_interleaved_i_to_s-00101.dcm
20180918114023.nii.gz axial_epi_fmri_interleaved_i_to_s-00051.dcm axial_epi_fmri_interleaved_i_to_s-00102.dcm
axial_epi_fmri_interleaved_i_to_s-00001.dcm axial_epi_fmri_interleaved_i_to_s-00052.dcm axial_epi_fmri_interleaved_i_to_s-00103.dcm
Here is how I am running it now.
$ bidsmapper.py . out
2019-11-24 16:15:19 - bidscoin - INFO
2019-11-24 16:15:19 - bidscoin - INFO -------------- START BIDSmapper ------------
2019-11-24 16:15:19 - bidscoin - INFO Reading: /media/data/hayashis/test/20180918GE/out/code/bidscoin/bidsmap.yaml
2019-11-24 16:15:19 - bidscoin - INFO Reading: /usr/local/lib/python3.6/dist-packages/heuristics/bidsmap_template.yaml
2019-11-24 16:15:22 - bidscoin - INFO Writing bidsmap to: /media/data/hayashis/test/20180918GE/out/code/bidscoin/bidsmap.yaml
2019-11-24 16:15:23 - bidscoin - INFO Opening the bidseditor
Traceback (most recent call last):
File "/usr/local/bin/bidsmapper.py", line 350, in <module>
interactive = args.interactive)
File "/usr/local/bin/bidsmapper.py", line 314, in bidsmapper
gui.setupUi(mainwin, bidsfolder, rawfolder, bidsmapfile, bidsmap_new, copy.deepcopy(bidsmap_new), template, subprefix=subprefix, sesprefix=sesprefix)
File "/usr/local/lib/python3.6/dist-packages/bidscoin/bidseditor.py", line 203, in setupUi
self.set_tab_bidsmap()
File "/usr/local/lib/python3.6/dist-packages/bidscoin/bidseditor.py", line 685, in set_tab_bidsmap
samples_table.setRowCount(num_files)
UnboundLocalError: local variable 'num_files' referenced before assignment
from bidscoin.
So you did the same as @dlevitas, you are using the subject folder as the sourcefolder. Bidscoin, like BIDS, works at the study level, meaning that it will convert all your subject data into BIDS. The sourcefolder is expected to contain sub-folders where each subfolder contains data for one subject. The session subfolder is then optional. Then it is assumed that in there you have all the files of one series (a "run" in BIDS speak) in one folder. That seems to be the case for you (but if not you can run dicomsort). So what you should do is to call the bidsmapper not with the .
argument but with its parent directory
from bidscoin.
I now changed the help text in:
sourcefolder: The study root folder containing the raw data in sub-#/[ses-#]/run subfolders (or specify --subprefix and --sesprefix for different prefixes)
@dlevitas and @soichih, Would that have helped sufficiently or do you have more suggestions which would have made your life easier? :-)
from bidscoin.
@marcelzwiers Thanks. I was seeing this with dicomsort.py
$ dicomsort.py 20180918GE/
>> Processing: /media/data/hayashis/test/20180918GE (0 files)
I didn't know that I had to rename the subject directory from mr_N to sub-N. I also didn't know that I can only run dicomsort.py for each subject directory (not the parent of it..) I still don't know exactly why I have to run dicomsort.py, but after running it successfully I was able to run bidsmapper.py. Thanks!
from bidscoin.
@soichih, you don't have to rename your subject directories, that is what the sub-prefix argument is for (so use something like bidsmapper.py --subprefix mr_ [..]
). Also you should be able to run dicomsort on the root level as well as on the subject level.
from bidscoin.
@marcelzwiers the edits to the help text make things a bit clearer now; thanks for doing that. Before it sounded as if it were asking for the directory with the run sub-folders.
from bidscoin.
Related Issues (20)
- Relative paths in provenance attribute of runs in the bidsmap HOT 3
- Fail to convert DWI DICOM files with Errorcode 139: Segmentation fault (core dumped)) HOT 3
- Does the combination of `nibabel2bids` with `spec2niibids` change a Nifti file or just rename it? HOT 6
- Support for CT images or guideline for user to add additional modalities HOT 8
- Can I use dynamic value to fill in a suffix HOT 14
- bidscoin pip install fails on apple silicon HOT 25
- Please clarify GPLv3 licensing HOT 3
- bidscoin automatically adds `*.nii*` to IntendedFor file name pattern HOT 2
- No module named 'pytest' while executing bidsmapper HOT 6
- Difficulty re-running bidscoiner with new participants (maybe file location related?) HOT 6
- Store user settings in a personal config file
- Update B0fieldmap/fieldsource when having multiple fieldmap runs
- Values in (0021,1106) vary per fmap acquisition HOT 1
- Add the possibility to track bidscoin usage HOT 6
- Take the `dir` value from dcm2niix's sidecar file HOT 1
- dicomsort outputfolder HOT 1
- Qt GUI toolkit not working on WSL 2 (kali-linux) HOT 7
- bidscoiner with -session option HOT 18
- spec2nii `anon` option does not create de-identified nii/json outputs HOT 5
- Update bidscoin on Neurodesk HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bidscoin.