Skip to content

Locations object has no attribute 'dr' #36

Description

@Fillot

Describe the bug
Trying to use infer fails.
Code is as follow :

#the localisation (untracked, obtained with trackmate), in x,y,t format
points = pd.read_csv('xyt_coords.txt') 

# here I'm trying to follow the code inside preset_analyser() of the tutorial notebooks.
a = RWAnalyzer()
a.spt_data.from_dataframe(points)
a.spt_data.frame_interval = dt = .01 # in s
a.spt_data.localization_precision = .02 # in µm
a.tesseller = tessellers.KMeans
a.tesseller.ref_distance = 0.02
a.sampler = sampler.Knn(10)
assignment_a = a.sampler.sample(points)

a.mapper = mapper.MapperPlugin('d')
d_map = a.mapper.infer(assignment_a)#<--- this fails here.

This fails with
AttributeError: 'Locations' object has no attribute 'dr'
in this case coming from inference/unsmooth_d.py -> infer_D

I think this is failing because infer_D expects TransLocations, not Locations, which is what it is being fed.
From this, my theory was that I needed to track beforehand, maybe that would put Translocations inside the cells.
I have used

b = RWAnalyzer()
b.spt_data.from_rwa_files('saved2.rwa')
b.spt_data.frame_interval = dt = .01 # in s
b.spt_data.localization_precision = .02 # in µm

b.tracker = tracker.from_non_tracking()
b.tracker.localization_precision = .02
b.tracker.estimated_high_diffusivity = 1
trajs = b.tracker.track('coords_tracked.xyt')

to get a tracking (here trying to load from a rwa file, but this changes nothing anyway.
then (here I was trying to imitate
https://github.com/DecBayComp/Stochastic_Integrals_Diffusivity/blob/master/ito-to-tramway/exemple_8.py

localization_error = 0.01
xyt_file = 'coords_tracked.xyt'
rwa_file = xyt_file.replace('.xyt', '.rwa')

xyt = load_xyt(xyt_file)
analysis_tree = Analyses(xyt)
save_rwa(rwa_file, analysis_tree, force=True)

cells = tessellate(analysis_tree, 'hexagon', ref_distance=0.5,
                           min_location_count=0, label='hexagon')
save_rwa(rwa_file, analysis_tree, force=True)
infer(analysis_tree, 'snr', input_label='hexagon', output_label='snr',
localization_error=localization_error, max_iter=50)

which still fails with the exact same error.

So I'm not sure how exactly I can ensure that infer_D gets cells with translocations attached.
Loading tracked data from a text file, or trying to pass around an Analyses, or loading rwa files doesn't seem to help.

System

  • Operating System: Ubuntu 20.04
  • Python version: 3.8.6
  • TRamWAy version: current (cloned this repo yesterday, 19 nov 2022)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions