yeatmanlab / AFQ-Browser

Browser-based visualization tools for AFQ results
BSD 3-Clause "New" or "Revised" License
33 stars 15 forks source link

AFQ-Browser metadata help #286

Closed dubergonzoni closed 3 years ago

dubergonzoni commented 3 years ago

I'm running AFQ_Browser with the outputs of pyAFQ. I have only two subjects. In pyAFQ outputs, I have the *profiles.csv of each subject ('sub-01_ses-01_dwi_profiles.csv' and 'sub-02_ses-01_dwi_profiles.csv').

After running AFQ-Browser in terminal: $ afqbrowser-assemble /home/eduardo/AFQ_data/pyAFQ_Tractography/derivatives/afq $ afqbrowser-run

My web browser (localhost:8080) shows the tract profiles of 3 patients and 3 controls in the metadata and in the plots.

Please, how can I set AFQ-Browser metadata and plots to show only the data of my two subjects analyzed in pyAFQ?

36000 commented 3 years ago

Hello! Thanks for getting in touch. One output of pyafq is the tract_profiles.csv file in derivatives/afq . If this file does not exist, run myafq.combine_profiles() where myafq is an AFQ.api object with the same parameters you originally used. This file is a combination of each of the individual CSVs.

If you replace the current afqbrowser/site/client/data/nodes.csv with this file , the tract profiles from pyAFQ will be shown in AFQ-Browser. You can also update afqbrowser/site/client/data/subjects.csv with the subject metadata.

dubergonzoni commented 3 years ago

Thank you Dr. Kruper for your quick reply.

I've tried to change the files but I was not successful. Follow attached the files I'm using as nodes.csv and subjects.csv

nodes.csv subjects.csv

Please, can you help me understand what I'm doing wrong? Is there anything wrong with these files?

arokem commented 3 years ago

Sorry this isn't working for you. I can take a look at this late tonight.

arokem commented 3 years ago

OK - thanks for providing these files. I think that I understand what's going on (and thanks for @36000 for pointing in the right direction in a private message!): first, I think that we need to do something with the pyAFQ-generated bundle names. We have "ARC_L", "ARC_R", etc., where AFQ-Browser expects "Left Arcuate", "Right Arcuate", etc. Second, the pyAFQ file has an extraneous column (the index column). Finally, the subjects file had a string value for every row. Here are nodes and subjects file that work when I replace them in, instead of your files. nodes.csv subjects.csv

dubergonzoni commented 3 years ago

I thank you Dr. Rokem and Dr. Kruper. Now I can see most of the bundles. I also can see the plots of the two subjects, but not the metadata information of your subjects.csv file above.

I have used the pyAFQ function "api.CALLOSUM_BUNDLES":

tracking_params = dict(seed_mask=RoiMask(), n_seeds=50000, random_seeds=True, rng_seed=42)

myafq = api.AFQ(bids_path=op.join(afd.afq_home, 'pyAFQ_Tractography_Callosum'), dmriprep='qsiprep', bundle_info=api.BUNDLES + api.CALLOSUM_BUNDLES, tracking_params=tracking_params)

With AFQ-Browser I can't see the segmented Callosum_BUNDLES?

Following the example provided in the github documentation, "Plotting Novel Tract Profiles", I can plot the Callosum Bundles. The plots of the tract-profiles I can generate separated. But I thought it would be possible to do that in AFQ-Browser. Please, It's possible?

36000 commented 3 years ago

We are currently fixing this. For AFQ-Browser, visualization depends on the streamlines.json file. This file is why we had to change the names from "ARC_L", "ARC_R", etc., to "Left Arcuate", "Right Arcuate", etc. It is also why the callosum bundles are not showing up in AFQ-browser. We are currently working on changing pyAFQ and AFQ-Browser to make their integration more seamless, however it will be a few weeks before these changes are finalized and well tested. As a part of these changes we are planning to make the streamlines.json file optional, and integrate our plotly pyAFQ visualizations as an option.

In the meantime, if you do not want to wait for these changes, you can update the streamlines.json file to include representative streamlines for the Callosum bundles, following the same format as the other bundles in that file. Just make sure the bundle names in streamlines.json correspond to the bundle names in nodes.csv under tractID.

Sorry for the late response, thank you for your patience!

dubergonzoni commented 3 years ago

Dear Dr. John Kruper. Thank you for your reply. I'm happy to know that AFQ team is working on the integration.

I will try to update the steamlines.json file, but I found tract names (not callosum) and another names like "coreFiber". How can I know which one of these "coreFiber"s represents a specific callosum tract?

I need to apologize for the delay in seeing your answer. I had to dedicate myself to solve family problems, but now I'm back to projects. Thank you!

36000 commented 3 years ago

Thank you for your patience! The "coreFiber" is a fiber whose nodes are the average of each other fiber's nodes. However, I don't think you will have to implement this yourself, because we have just updated pyAFQ with a feature to automatically set up an AFQ-Browser instance! You can install the updated pyAFQ from master here: pip install git+https://github.com/yeatmanlab/pyAFQ.git

Using the newly updated pyAFQ, if you set up myafq with the same parameters, it should use what you have already calculated. You can call either: myafq.export_all() or myafq.assemble_AFQ_browser() and it will generate an afq browser instance in a folder in your_bids_path/derivatives/afq_browser

We would love any feedback on this new feature!

dubergonzoni commented 3 years ago

Great to hear about the update of pyAFQ.

I'm trying to run but I'm getting the following error:

ImageFileError: Cannot work out file type of "/home/edu_asus/AFQ_data/New_pyAFQ_afqbrowser_Callosum/derivatives/afq/sub-01/ses-01/sub-01_ses-01_dwi_mapping_from-DWI_to_MNI_xfm.nii.gz"

Trying to open this file with another software I got the same error. The file is corrupted?

Thank you

36000 commented 3 years ago

Try deleting the file and re-running the software. If the same error comes up, could you send me the file and I can check it out?

dubergonzoni commented 3 years ago

I have tried deleting and re-running. The same error comes up. I think I can't attach a .nii file here. Please, how can I sent you the file?

As soon as possible, I will also try to run in a computer with more RAM. Thank you!

36000 commented 3 years ago

It looks like you have found a bug in this version of pyAFQ. If you are concerned with RAM, try turning off parallelization, which this version of pyAFQ does by default. You can turn off parallelization by passing this argument to api.AFQ: parallel_params={"engine": "serial"} Based off of what you posted above, the full call would look like this:

myafq = api.AFQ(
    bids_path=op.join(afd.afq_home,
                                    'pyAFQ_Tractography_Callosum'),
    dmriprep='qsiprep',
    bundle_info=api.BUNDLES + api.CALLOSUM_BUNDLES,
    parallel_params={"engine": "serial"},
    tracking_params=tracking_params)

Meanwhile, I will try to reproduce this bug on my end. You can send me the .nii file by putting it in a .zip folder and uploading that to github, or by renaming it to end in ".txt". Thank you for your patience!

dubergonzoni commented 3 years ago

I thank you so much, Dr. Kruper, for your patience. Now it's all running perfectly! Congrats AFQ team for this incredible work integrating all the softwares!!

36000 commented 3 years ago

Thank you for the help! @arokem I think the parallelization was having trouble here with file I/O for some unknown reason. Maybe we should make serial default until we have more experience with parallelization?

arokem commented 3 years ago

@dubergonzoni : glad to hear this works for you!

@36000 : Maybe we should post an issue on the pyAFQ repo to track this? Do you have more clues about this then just this comment?