Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brkraw not working with a dataset #41

Closed
ycAbout opened this issue Mar 4, 2021 · 6 comments · Fixed by #45
Closed

brkraw not working with a dataset #41

ycAbout opened this issue Mar 4, 2021 · 6 comments · Fixed by #45

Comments

@ycAbout
Copy link
Contributor

ycAbout commented Mar 4, 2021

Describe the bug
brkraw works with the example bruker2nifti_qa dataset.
brkraw does not work with another dataset.
Specifically, with another dataset
brkraw bids_helper <dataset> <outputfile> -j works, but produced an empty .xlsx file within only column names.
brkraw bids_convert <dataset> <.xlsx> -j <.json> -o <output folder> does not work, with the following error:

  File "/usr/local/bin/brkraw", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/brkraw/scripts/brkraw.py", line 393, in main
    dset = BrukerLoader(dpath)
  File "/usr/local/lib/python3.7/site-packages/brkraw/lib/loader.py", line 89, in __init__
    self._pvobj = load(path)
  File "/usr/local/lib/python3.7/site-packages/brkraw/lib/loader.py", line 17, in load
    return PvDatasetDir(path)
  File "/usr/local/lib/python3.7/site-packages/brkraw/lib/pvobj.py", line 146, in __init__
    self._parse_info()
  File "/usr/local/lib/python3.7/site-packages/brkraw/lib/pvobj.py", line 163, in _parse_info
    if len(root.split(os.sep)) == root_path_fregs + 1:
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Tried to debug, but not very fruitful. It requires more background information about the project.
However, this might be helpful:
for a sub folder containing following files:
['AdjStatePerScan', 'specpar', 'acqp', 'fid', 'uxnmr.par', 'uxnmr.info', 'method', 'configscan', 'pulseprogram', 'visu_pars']
The root_path_fregs would be None, causing 'method' condition root_path_fregs + 1 error:

        for root, subdir, files in os.walk(self.__path):
            if 'subject' in files:
                if root_path_fregs is None:
                    root_path_fregs = len(root.split(os.sep))
                    with open(os.path.join(root, 'subject'), 'r') as f:
                        self._subject = Parameter(f.read().split('\n'))
                else:
                    pass
            elif 'method' in files and 'acqp' in files:
                if len(root.split(os.sep)) == root_path_fregs + 1:

cc
@gdevenyi

@gdevenyi
Copy link
Collaborator

gdevenyi commented Mar 4, 2021

  1. I don't think xlsx is valid for an output. It makes csvs.
  2. Already reported and fixed in dev, tonii_all crashes if run against a bruker study directory #27

@ycAbout
Copy link
Contributor Author

ycAbout commented Mar 4, 2021

  1. I don't think xlsx is valid for an output. It makes csvs.
  2. Already reported and fixed in dev, tonii_all crashes if run against a bruker study directory #27

Hi Gabriel,

  1. If you follow the documentation here: https://brkraw.github.io/docs/gs_bids.html, a .xlsx will be produced and it is required for next step. If you mean xlsx should be replaced by csv by brkraw internally, I agree. And another json file is also an option (I like this one better).
  2. Although they seems similar, but they are not the same issue. I simply installed the newest master branch (which already contains the fix of tonii_all crashes if run against a bruker study directory #27), this issue persists.

@gdevenyi
Copy link
Collaborator

gdevenyi commented Mar 4, 2021

Ugh that is an excel file, it should definitely not be. Please open a separate issue for that.

Based on some more reading here, the .xlsx file needs to be populated to guide the conversion properly. Considering its "empty" bids_convert fails, although it should throw an error.

@gdevenyi
Copy link
Collaborator

gdevenyi commented Mar 4, 2021

See #11 for a workflow of how the helper is used.

@mabast85
Copy link

mabast85 commented Mar 5, 2021

Hi,

similar issue here: when trying to convert my own study using tonii_all, I get the same message, i.e.:

$ brkraw tonii_all /Users/matteob/RatScans/20210302_100344_B_B_rat4d_1_1
Traceback (most recent call last):
File "/Users/matteob/miniconda3/miniconda3/envs/myfslpython603/bin/brkraw", line 8, in
sys.exit(main())
File "/Users/matteob/miniconda3/miniconda3/envs/myfslpython603/lib/python3.7/site-packages/brkraw/scripts/brkraw.py", line 184, in main
study = BrukerLoader(sub_path)
File "/Users/matteob/miniconda3/miniconda3/envs/myfslpython603/lib/python3.7/site-packages/brkraw/lib/loader.py", line 93, in init
self._pvobj = load(path)
File "/Users/matteob/miniconda3/miniconda3/envs/myfslpython603/lib/python3.7/site-packages/brkraw/lib/loader.py", line 21, in load
return PvDatasetDir(path)
File "/Users/matteob/miniconda3/miniconda3/envs/myfslpython603/lib/python3.7/site-packages/brkraw/lib/pvobj.py", line 145, in init
self._parse_info()
File "/Users/matteob/miniconda3/miniconda3/envs/myfslpython603/lib/python3.7/site-packages/brkraw/lib/pvobj.py", line 160, in _parse_info
if len(root.split(os.sep)) == root_path_fregs + 1:
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

It does not help if I am in the parent directory or not, the error is the same. Any ideas what may be going wrong?

@gdevenyi
Copy link
Collaborator

gdevenyi commented Mar 5, 2021

@mabast85 can you please open a seperate issue. Also please share the output of find or tree on the directory you're trying to convert and the version of brkraw you're using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants