JohnDieSchere / quickpbsa

GNU General Public License v3.0
1 stars 7 forks source link

Problems with extracting trace from mask #4

Open mocarl opened 6 months ago

mocarl commented 6 months ago

Hi, Thank you for your work and well working. I have successfully used your program previously to quantify number of proteins in the center of stationary punctas. At the moment though I want to extract the trace from a larger structure and therefore want to use the extract_traces_mask function in order to capture the decay across the entire structure. Unfortunately I can't get the function to work properly. I have attached the error below. As far as I can see it is simple problem of getting arrays with differing shapes. I can't seem to find in which step this problem occurs though.

The ingoing mask is a 8-bit image with 0 representing background and 255 for signal. The tiffstack from which to get a trace is a 1000 images 16-bit stack.

Thank you in advance,

    "name": "ValueError",
    "message": "operands could not be broadcast together with shapes (1000,45) (16,) ",
    "stack": "---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[31], line 26
     23 r_bg = 6 #a width of r_bg is defined for background correction
     25 #pbsa.trace_extraction.extract_traces_localization(tiffstack, tsout, rpeak, rbg1, rbg2, mindist, binning = 10)
---> 26 pbsa.trace_extraction.extract_traces_mask(tiffstack, maskfile, dist, r_bg, binning=10)
     28 tracefile = path + '_difference.csv'
     29 print(tracefile)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/quickpbsa/trace_extraction/from_mask.py:191, in extract_traces_mask(tiffstack, maskfile, dist, r_bg, roifile, range_area, range_size, binning)
    188 export_mask(bgsel, outfile_bgmask, pardict)
    190 #### Extract traces from stack and save to csv ############################
--> 191 peak, bg = traces_from_stack(tiffstack, peaksel, bgsel, peakpix, bgpix, binning)
    192 outfile_peak = outpath + '/' + fname + '_peak.csv'
    193 export_csv(basedf, peak.T, outfile_peak, pardict)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/quickpbsa/trace_extraction/helpers.py:46, in traces_from_stack(stack, peaksel, bgsel, peakpix, bgpix, binning)
     44 # peak traces
     45 peak = data[:, peaksel]
---> 46 peak = np.sum(peak, 1) / peakpix
     47 # bg traces
     48 bg = data[:, bgsel]

ValueError: operands could not be broadcast together with shapes (1000,45) (16,) "