jlevy44 / PathFlow-MixMatch

Don't mix, match! Simple utilities for improved registration of Histopathology Whole Slide Images.
10 stars 6 forks source link

Why is that n_components of PCA in def get_matched_tissue is 4? #25

Open gmh1033286494 opened 3 years ago

gmh1033286494 commented 3 years ago

I run with no_segement_analysis = False and get this error

ValueError: n_components=4 must be between 0 and min(n_samples, n_features)=2 with svd_solver='full'

So I set n_components = 2 and the code worked but the result is only half of the image.

I am wondering why this happens. image

jlevy44 commented 3 years ago

Hi @gmh1033286494 , you may be running an older version of mixmatch, you may want to pip install the code in this branch, though it is experimental: https://github.com/jlevy44/PathFlow-MixMatch/tree/fix_nonlinear_memory_issues

We are still refactoring, but let me know if you still get the pca issue, shouldn't be running. Also check for typos in your command specification.

gmh1033286494 commented 3 years ago
test = Commands()

test.register_images(im1 = '/home/chixing/fixed_im_grey_r16.png',im2 = '/home/chixing/moving_im_grey_r16.png',fix_rotation = False,output_dir='/home/chixing/result/',gpu_device = 0,transform_type = 'rigid',lr = 0.01,iterations = 10,min_object_size = 500,no_segment_analysis = False,black_background = True
)

I still get the same PCA error using the 'fix_nonlinear_memory_issues' version. Above is what I used in the my command specification.

BTW, how to pip install this branch?

pip install git+https://github.com/jlevy44/PathFlow-MixMatch.git This seems to only install the code in the master. So instead I copy the code in cli.py into a jupyter notebook and run it.

sumanthratna commented 3 years ago

BTW, how to pip install this branch?

@gmh1033286494 I think this should work: pip install "git+https://github.com/jlevy44/PathFlow-MixMatch.git@fix_nonlinear_memory_issues#egg=pathflow_mixmatch"

gmh1033286494 commented 3 years ago

BTW, how to pip install this branch?

@gmh1033286494 I think this should work: pip install "git+https://github.com/jlevy44/PathFlow-MixMatch.git@fix_nonlinear_memory_issues#egg=pathflow_mixmatch"

It worked but still got the same PCA error. I am using dapi channel of 2 4000*5000 sequently sliced mIHC grey scale images as fixed and moving image. Format is png.

jlevy44 commented 3 years ago

Can you try setting no_segment_analysis = True ?

gmh1033286494 commented 3 years ago

Can you try setting no_segment_analysis = True ?

It is working when no_segment_analysis = True. But I am thinking whether with segment_analysis the result will be better and the speed will be faster. Besides when no_segment_analysis = True, my GPU can only support image as largest as 5000 7000,I wondering if with segment_analysis I can use larger fixed and moving image. If I remembered correct you mention mixmatch could support about 50000 50000 wsi.

Thank you.

jlevy44 commented 3 years ago

With segment analysis, it assumes that your image can be broken into various smaller connected components, is this true in your case?

gmh1033286494 commented 3 years ago

With segment analysis, it assumes that your image can be broken into various smaller connected components, is this true in your case?

I don't know if my test image can be broken into various smaller connected components(probably not). Could you give me some examples or test images?

jlevy44 commented 3 years ago

if the image is the one you had sent in #26 , I'm not sure the segmented analysis is applicable.. you need to have clear separation of the components. In histology, this may be applicable for an FNA biopsy. In the future, we do plan to have some pre-clustering algorithm to find corresponding clusters of segments to register, but is not currently a priority