Closed beatrizserrano closed 6 years ago
You should be able to either wrap the generator with a list
:
tile = list(getTiles())[0]
or iterate over it breaking as necessary:
for tile in getTiles():
tile...
break
What do you mean by "save"? Can you show us the rest of what you're trying to do? Perhaps similar is the getRohnTile
method from https://github.com/IDR/idr-notebooks/blob/master/notebooks/RohnPhenotypeClustering.ipynb
Thanks, Josh. I was thinking to save the plane that the getRohnTile
method returns into my tenancy but it doesn't make sense since I could compute the features directly over the numpy matrix.
Here’s my code to do that:
from idr import connection
conn = connection()
image = conn.getObject("Image", 567984)
cropParams = (336, 256, 672, 512) # x, y, width, height
imageROI = image.getPrimaryPixels().getTile(theC=1, tile=cropParams)
conn.close()
from wndcharm.PyImageMatrix import PyImageMatrix
matrix = PyImageMatrix()
matrix.allocate(imageROI.shape[1], imageROI.shape[0])
numpy_matrix = matrix.as_ndarray()
numpy_matrix[:] = imageROI
from wndcharm.FeatureVector import FeatureVector
fv = FeatureVector(name='FromNumpyMatrix', long=True, original_px_plane=matrix)
fv.GenerateFeatures(quiet=False, write_to_disk=True)
However, I'm now facing a new issue :) Wnd-charm doesn't seem to be installed, I've tried this but to no avail:
!conda install --yes --prefix {sys.prefix} wndcharm
Is there any way to use wndcharm package in my notebook?
Thanks!
I was thinking to save the plane that the getRohnTile method returns into my tenancy but it doesn't make sense since I could compute the features directly over the numpy matrix.
Exactly. For this preliminary testing, the binary day stays in the IDR jupyter and some (minimal) processing can be done on it. When the full version using the public API, the communication overhead would be in getting thetile
to your tenancy, where you then do the processing.
Is there any way to use wndcharm package in my notebook?
I haven't tested this thoroughly, but this looks like it would get you started:
%%bash
conda install -y -c eumetsat fftw3
conda install -y -c anaconda libtiff
test -e wnd-charm || git clone --depth=1 https://github.com/wnd-charm/wnd-charm.git wnd-charm
cd wnd-charm
%%bash
touch aclocal.m4 Makefile.in configure config.h.in
export CFLAGS="-L/opt/conda/lib -I/opt/conda/include"
export CXXFLAGS="$CFLAGS"
./configure --prefix=/opt/conda/
make install
afterwards
!/opt/conda/bin/wndchrm
produces
wndchrm 1.60-de98947. Laboratory of Genetics/NIA/NIH
usage:
======
wndchrm [ train | test | classify | check ] [-mtslcdowfrijnpqvNSBACDTh] [<dataset>|<train set>] [<test set>|<feature file>] [<report_file>]
Hi!
I'd like to save the resulting image after getting a particular tile and plane. This is my code:
Looks like imageROI is a generator object. I guess that this is the way of getting each tile for a give set of sizes. In my case, I just need one tile so I tried with imageROI.next() but it doesn't work. Also I've tried with imageROI.save(). Any thoughts on how to save this particular ROI?