Giter Site home page Giter Site logo

connectomicslab / aneurysm_detection Goto Github PK

View Code? Open in Web Editor NEW
28.0 2.0 7.0 56.73 MB

This repository contains the code used for the paper "Towards automated brain aneurysm detection in TOF-MRA: open data, weak labels, and anatomical knowledge "

License: Apache License 2.0

Python 100.00%
deep-learning detection segmentation tof-mra weakly-supervised-detection anatomical-knowledge aneurysm

aneurysm_detection's People

Contributors

siddhi47 avatar tommydino93 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aneurysm_detection's Issues

Incorrect session dates for subjects

Hi there! Thank you for this repository.

I am playing around with the inference code when I realised that the participants.tsv file in the dataset downloaded from OpenNeuro contains session dates that do not align with all_test_subs_inhouse.pkl in the extra_files directory of this repository.

image

As seen above, the session date for sub-000 in the OpenNeuro dataset is 20110101 but in the given pkl file, it is 20101230. Same goes for the other pkl files in extra_files such as patients_with_voxelwise_labels.pkl, patients_with_weak_labels.pkl and the pkl files in Forced_CV_for_reproducibility.

Therefore, after running the inference step of the pipeline as described in the README, using the available train outputs/weights provided in extra_files, inference results were produced for only 6 patients across the 5 folds, as majority of the testing subject-sessions in each fold does not exist in the OpenNeuro dataset at all.

I tried running the pipeline from step 1 and training the network myself, but the result is the same as Forced_CV_for_reproducibility is used to restore the subject-session names.

image

(Notice how the session date for sub-005 in the output of self_trained is different from that in participants.tsv)

Are the contents of extra_files currently outdated with the OpenNeuro dataset? I am not super experienced with this and have not engaged with a project of this scale, so apologies if I am misunderstanding anything!

Positive patches creation error

Hi @tommydino93,
I am new to Python and Github communities so please excuse me if my question is naive or inexperience in anyway.

When I try to follow your code, I got an error during the dataset_creation process, the positive patches creation to be specific (the negative patches creation process runs smoothly). The following error are one example when I try to run on 1 sample only (sub-075). The error seems like it is due to the fact that the code cannot create a temporary patch for the first lesion_1 unlike the negative patch. Do you have any idea why it leads to this problem? I copy the error below.

Thank you in advance for your kind reply if possible.

Began extraction of positive patches...

-------------------------- sub-075_ses-20100502_Lesion_1 --------------------------
Traceback (most recent call last):
File "E:\Projects\Cerebral_Aneurysm_Segmentation\Aneurysm_Detection-main\dataset_creation\create_dataset_patches_neg_and_pos.py", line 606, in
main()
File "E:\Projects\Cerebral_Aneurysm_Segmentation\Aneurysm_Detection-main\dataset_creation\create_dataset_patches_neg_and_pos.py", line 583, in main
create_patch_ds(bids_dataset_path,
File "E:\Projects\Cerebral_Aneurysm_Segmentation\Aneurysm_Detection-main\dataset_creation\create_dataset_patches_neg_and_pos.py", line 486, in create_patch_ds
Parallel(n_jobs=n_parallel_jobs, backend='loky')(delayed(extract_positive_patches)(all_subdirs[idx],
File "c:\Users\ADMIN\anaconda3\envs\tensorflow-gpu\lib\site-packages\joblib\parallel.py", line 1863, in call
return output if self.return_generator else list(output)
File "c:\Users\ADMIN\anaconda3\envs\tensorflow-gpu\lib\site-packages\joblib\parallel.py", line 1792, in _get_sequential_output
res = func(*args, **kwargs)
File "E:\Projects\Cerebral_Aneurysm_Segmentation\Aneurysm_Detection-main\dataset_creation\create_dataset_patches_neg_and_pos.py", line 363, in extract_positive_patches
nib.save(patch_mask_obj_translated_scale_1, os.path.join(pos_patches_masks_path, patch_mask_name_transl_scale_1))
File "c:\Users\ADMIN\anaconda3\envs\tensorflow-gpu\lib\site-packages\nibabel\loadsave.py", line 163, in save
img.to_filename(filename, **kwargs)
File "c:\Users\ADMIN\anaconda3\envs\tensorflow-gpu\lib\site-packages\nibabel\filebasedimages.py", line 307, in to_filename
self.to_file_map(**kwargs)
File "c:\Users\ADMIN\anaconda3\envs\tensorflow-gpu\lib\site-packages\nibabel\nifti1.py", line 2219, in to_file_map
super().to_file_map(file_map, dtype)
File "c:\Users\ADMIN\anaconda3\envs\tensorflow-gpu\lib\site-packages\nibabel\analyze.py", line 1037, in to_file_map
hdrf = hdr_fh.get_prepare_fileobj(mode='wb')
File "c:\Users\ADMIN\anaconda3\envs\tensorflow-gpu\lib\site-packages\nibabel\fileholders.py", line 74, in get_prepare_fileobj
obj = ImageOpener(self.filename, *args, **kwargs)
File "c:\Users\ADMIN\anaconda3\envs\tensorflow-gpu\lib\site-packages\nibabel\openers.py", line 182, in init
self.fobj = opener(fileish, *args, **kwargs)
File "c:\Users\ADMIN\anaconda3\envs\tensorflow-gpu\lib\site-packages\nibabel\openers.py", line 91, in _gzip_open
gzip_file = DeterministicGzipFile(filename, mode, compresslevel, mtime=mtime)
File "c:\Users\ADMIN\anaconda3\envs\tensorflow-gpu\lib\site-packages\nibabel\openers.py", line 72, in init
fileobj = self.myfileobj = ty.cast(io.FileIO, open(filename, modestr))
FileNotFoundError: [Errno 2] No such file or directory: 'E:/Projects/Cerebral_Aneurysm_Segmentation/Aneurysm_Detection-main/output_dataset_path_temp\Data_Set_Dec_01_2023_unique_identifier\Positive_Patches_Masks\sub-075_ses-20100502_Lesion_1\patch_pair_1\sub-075_ses-20100502_Lesion_1_patch_pair_1_transl_mask_patch.nii.gz'

Possible Performance Improvement

Hi! I was browsing repos that were using cc3d recently to see how people are using it. I noticed in your repo that there was a spot that looked slow that could be improved fairly easily.

labels_out = cc3d.connected_components(np.asarray(hard_threshold_patch, dtype=int))
numb_labels = np.max(labels_out) # extract number of different connected components found
numb_non_zero_voxels = []
for seg_id in range(1, numb_labels + 1): # loop over different labels (i.e. conn. components) found
extracted_image = labels_out * (labels_out == seg_id) # extract one conn. component volume
numb_non_zero_voxels.append(np.count_nonzero(extracted_image)) # append number of non-zero voxels for this conn. component volume
largest_conn_comp_value = np.argmax(numb_non_zero_voxels) + 1
largest_conn_comp_binary = hard_threshold_patch * (labels_out == largest_conn_comp_value)

        largest_conn_comp_binary = cc3d.largest_k(labels_out, k=1)

If that's not useful to your project, please feel free to ignore this as I don't want to waste your time. Good luck!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.