-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to Composite PatternGenerator subobject parameters #13
Comments
Submitted by jbednar We've now made it easier to edit mask_shape in the Test Pattern window; one can simply select any PatternGenerator and then right click to change its parameters. So the GUI should now support masked patterns very well. Arbitrary composite patterns, however, still require a new class with special mapping between its parameters and those of its subobjects. |
Submitted by ceball Could we go with the idea of 'promoting' parameters? In Composite: def init(self,**params): def getattr(self,name): def setattr(self,name,val): def promote_attr(self,name,obj): Code like that would allows the following: ceball@cloud:~/t/topographica$ ./topographica -i -p topo_t000000.00_c2>>> inputs[0].aspect_ratio topo_t000000.00_c3>>> inputs[0].aspect_ratio=2.0 topo_t000000.00_c4>>> inputs[0].generators[2].aspect_ratio topo_t000000.00_c5>>> inputs[0].generators[2].aspect_ratio=3 topo_t000000.00_c6>>> inputs[0].aspect_ratio (We'd also have to do something for the params() method, which e.g. |
Submitted by nobody (Added email discussion; still haven't resolved the issues) From: C. E. Ball On Mon, Mar 9, 2009 at 00:45, James A. Bednar <[email protected]> wrote:
Seems like it would be convenient, and I support the . notation in I don't, however, see how this will solve our original problem
I don't see a problem with that code (except that the assert should be In fact, trying it now, I find it works: ceball@cloud:~/t/topographica$ svn diff + def getattr(self,name):
Input patternsnum_inputs=3
righteye = pattern.Gaussian(aspect_ratio = 1.0, x = 1/24.0, y = -2.5/24.0,
mouth = pattern.Gaussian(aspect_ratio = 1.0, x = -5/24.0, y = 0.0/24.0,
inputs=[pattern.Composite(generators = [lefteye, righteye, mouth], This reminded me that we still want to deal with the general problem. Could we go with the idea of 'promoting' parameters? In Composite:
Ignoring the earlier changes for named subpatterns, code like this ceball@cloud:~/t/topographica$ ./topographica -i -p topo_t000000.00_c2>>> inputs[0].aspect_ratio topo_t000000.00_c3>>> inputs[0].aspect_ratio=2.0 topo_t000000.00_c4>>> inputs[0].generators[2].aspect_ratio topo_t000000.00_c5>>> inputs[0].generators[2].aspect_ratio=3 topo_t000000.00_c6>>> inputs[0].aspect_ratio (We'd also have to do something for the params() method, which e.g. Have I missed something? 'Automatic promotion' (i.e. no promote_param(), instead finding the Chris |
Converted from SourceForge issue 2144996, submitted by jbednar
Submit Date: 2008-10-03 20:11 GMT
Classes like SineGratingDisk, SineGratingRectangle, SineGratingRing, are redundant, because a Composite can easily do any of those things, but they have proliferated because a Composite does not make it easy to control the parameters of the underlying object. The special-purpose classes define various parameters at the top level, and then (in principle) apply those to the underlying pattern. That way the patterns can be used in the Test Pattern window, and (even more importantly) for measuring tuning curves and maps. We would all like a much more general way to define such patterns, so that new patterns don't require writing a new, complicated class.
For the very common special case of a pattern with a mask of some shape, a simple approach is to use the ConnectionField mask. I added code today to make that work well, and now e.g. SineGratingDisk can be written as simply:
or even SineGrating(mask_shape=Disk(smoothing=0)) (without needing a new class, though this version won't show up in the Test Pattern window). This takes care of SineGratingDisk, SineGratingRectangle, SineGratingRing, and any other pattern masked by a simple shape.
However, it doesn't help the general case of controlling the subpatterns of a Composite. E.g. GaussianCloud doesn't fit, because we typically use that for ConnectionField patterns, and CFProjections override the masks to make them circular or some other shape. OrientationContrastPattern consists of two concentric rings, and thus isn't just a masked pattern either.
As a first step, I've cleaned up GaussianCloud as an example of how those classes can work best now (e.g. r9389), by inheriting from Composite and passing the value of a few specially defined parameters down to subobjects. This approach works well, but it does require defining a new class and new parameters, rather than just passing some parameters to Composite.
To solve the problem completely, I think this plan would work:
Change Composite.generators into a
dictionary, instead of a list, so that every
subobject has a name. For backwards
compatibility, the Composite constructor
would probably need to continue accepting a
list, but then generate arbitrary unique
names (obj1, obj2, etc.) and put them into a
dictionary. New code would then use a
dictionary, with names for each object.
Add a method to Composite to shadow the
parameters of an underlying object in a
general way, e.g. parameter "orientation" of
object "sine" would show up as parameter
"sine.orientation" or maybe
"sine:orientation". Two ways this could
work:
a) Like TkParameterizedBase,
i.e. automatically mapping everything in an
underlying object into the Composite, using
the special names as above. The advantage
of this is is that any Composite would work
automatically. However, the list of
parameters will quickly get quite huge, with
only a few of them actually useful to expose
at the top level, which will make the Test
Pattern window nearly unusable.
b) We could add method for promoting only
specific subobject parameters to the top
level, potentially allowing shorter names
(e.g. 'frequency' could be promoted as
'frequency' rather than 'sine.frequency',
because Composite doesn't have any frequency
parameter to conflict. However, this
requires specific work to make the subobject
parameter available at the Composite level,
and I don't know if that's appropriate.
There may also be some middle ground between these two.
In any case, this all seems feasible, and doesn't require e.g. parsing any special string languages as I had originally feared. (Even though parameter names are like "sine.frequency", we don't need to break it into "sine" and "frequency", because the mapping mechanism should make the subobject parameter show up as a Composite parameter that just happens to be named "sine.frequency", and so we don't need to do any further text processing.
If anyone wants to work on this, please let me know. It seems pretty concrete now; it used to seem too vague even to attempt...
The text was updated successfully, but these errors were encountered: