flevet / PoCA

https://poca-smlm.github.io/
18 stars 2 forks source link

Please add instructions for using CAML in PoCA #4

Closed IAmSuyogJadhav closed 3 months ago

IAmSuyogJadhav commented 9 months ago

Hi, I am trying to utilise the python plugin feature in PoCA to run CAML on some datasets. I tried to use the CAML files found inside pythonScripts folder. The scripts make the GUI program crash. So, I tried to run the python files separately. I created a JSON file from CAML's instructions, and changed other paths as needed. On trying to feed a sample data of 100 points (only 2D, as thetestCAMLfunction only seems to acceptxsandys` as arguments. Not sure how to make it work for 3D data), the function runs indefintely (did not produce a result after running for 1 day continuously).

It seems to be stuck in a while loop ?

KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-6-1d52d11664cb> in <module>
----> 1 testCAML(infos, xs, ys)

/mnt/c/Users/suyog/projects/thesis/poca/poca.0.8.0/pythonScripts/CAML_linux.py in testCAML(infos, xs, ys)
    348         # If you want to do single-thread processing do this:
    349         for i in range(TotalPointsThisImage):
--> 350             fn_distcalc.dnns_v3(datatable_mmapped, datatable_mmapped, ps, dists_mmapped, i)
    351             if np.mod(i, 1000) == 0:
    352                 elapsed_time = time.time() - start_time

/mnt/c/Users/suyog/projects/thesis/poca/poca.0.8.0/pythonScripts/FuncDistCalcs.py in dnns_v3(inputdata1, inputdata2, ps, output_filename, i)
     97     while not UseableRegion:
     98         TestRegBounds = [np.floor(inputdata1[0, ps['xCol']] - TestRegionSize),
---> 99                          np.ceil(inputdata1[0, ps['xCol']] + TestRegionSize),
    100                          np.floor(inputdata1[0, ps['yCol']] - TestRegionSize),
    101                          np.ceil(inputdata1[0, ps['yCol']] + TestRegionSize)]

[~/anaconda3/envs/caml_temp/lib/python3.7/site-packages/numpy/core/memmap.py](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/suyog/projects/thesis/poca/poca.0.8.0/pythonScripts/~/anaconda3/envs/caml_temp/lib/python3.7/site-packages/numpy/core/memmap.py) in __getitem__(self, index)
    329 
    330     def __getitem__(self, index):
--> 331         res = super(memmap, self).__getitem__(index)
    332         if type(res) is memmap and res._mmap is None:
    333             return res.view(type=ndarray)

KeyboardInterrupt:

Can you please add instructions on how to setup CAML to work with PoCA? Do let me know if you need information from me. I tried this with PoCA release 0.8.0. Thank you!

flevet commented 9 months ago

Hi,

So I tested on my development setup (it's been a while since I tried) and I managed to make it work.

First, the error you point to is related to CAML. As I'm not the developer of CAML I'm not able to help with that, I just managed (very inefficiently) to merged their method from several files to one. Nevertheless, did you follow their steps to make CAML works on Windows? They point to a very specific Python distribution as seen here: https://gitlab.com/quokka79/caml/-/wikis/Setting%20Up%20Windows%20WinPython

Did you use this distrib?

To make the CAML.py work, I modified it slightly:

def testCAML(xs, ys):
    print("We are here")
    with open(input_PrepJSON, 'r') as file:
        print (xs)
        w, h = np.ceil(np.max(xs)), np.ceil(np.max(ys))
        infos = [w, h, 0, 0, w, 0, h, 0, 0]
        dataTest = np.array([xs, ys])
        print(dataTest)

And then used this setting from PoCA v0.8.0: poca_caml

Obviously, you also need to change the different paths in CAML.py: input_PrepJSON = path/caml-master/CAMLtutorial/AAA Data Descriptions.json' inputpath = 'path/caml-master/CAMLtutorial' current_file = '1_PpMS(100.0)_PpC(20)_PC(50.0)_r(0.0-40.0)_CpMS(2.5)_cellID(1).tsv' s1_prep_outputpath = 'path\caml-master\CAMLtutorial\testFlorian' model_fname = 'path\caml-master\CAMLtutorial\testFlorian\model\07VEJJ - Norm-Self Train(500.0k,0.5×Clus) Val(100.0k,0.5×Clus).h5'

I just give you this dropbox link to the folder testFlorian: https://www.dropbox.com/sh/vorbluhmtnr8e8m/AABNKcoAxowdu52l_TRFzlMZa?dl=0 It's been a long time I did that so I don't exactly remember what I did for this folder. Pretty sure I just picked some of the files of the tutorials and put them here.

IAmSuyogJadhav commented 9 months ago

Hi, Thank you for your response. I will try it out again and let you know how it goes with the modified code. :)

flevet commented 3 months ago

Closing the issue as there was no follow-up