loopy icon indicating copy to clipboard operation
loopy copied to clipboard

FEAT import/export node data

Open jimtobias opened this issue 5 years ago • 7 comments

I'd like to be able to use external data from a spreadsheet or text file to set starting conditions, and preferably to use live changes to that data source.

jimtobias avatar Mar 23 '20 08:03 jimtobias

With a proper csv to json conversion, i think it's already possible

1000i100 avatar Mar 25 '20 06:03 1000i100

Do you mean an external tool that does the conversion? Good, but doing it internally would be better, of course. Any external tool excludes many potential users who are attracted to loopy for its simplicity.

Can you point me to such a tool so I can try it? (Warning: not a code genius over here.)

jimtobias avatar Mar 25 '20 08:03 jimtobias

Also not a code genius, but am pretty handy in Python (and equally clueless in everything else but like SQL).

Have been playing with networkx, a killer Python library for doing all things graph/network. It's got great data (de)serialization tools and more graph algorithms and statistics than I understand, let alone could list.

Interested in figuring out a way to translate between code-generated stuff in networkx and more freeform stuff built in loopy.

Trying to read through the JavaScript, despite not knowing a thing about JavaScript, and it's raising more questions than answers, lol

In all seriousness, I exported a .loopy file and opened it up in a text editor. Looks like the same info as is contained in the URL when I build one on the webapp. Was hoping someone could help me grok what what I'm looking in the output of this model (formatted for clarity). It's obviously some list of tuples describing the nodes and then the edges, however, I'd appreciate it if someone could help me make heads or tails of what I'm looking at-- particularly interested in understanding how it establishes "linkage" between any two nodes

[[[1,504,451,0,"depression",0],[2,837,448,0,"doing%20things",4],[3,673,281,0,"de-motivation",1],
[4,1008,282,0,"fear%20of%20mistakes",1],[5,1166,455,0,"anxiety",0],[6,1005,634,0,"accepting%20mistakes",4],
[7,670,639,0,"feeling%20good",4]],[[2,7,59,1,0],[2,6,-61,1,0],[6,5,-59,-1,0],[5,4,-57,1,0],[4,2,-53,-1,0],[3,2,56,-1,0],[1,3,66,1,0],
[7,1,63,-1,0]],[[671,462,"a%20possible%0Asystems-
level%0Aexplanation%20for%0Awhy%20depression%20%26%0Aanxiety%20are%20not%20just%0Aco-
morbid%2C%20but%0AMUTUALLY%20SELF-%0AREINFORCING"],
[1001,466,"CHALLENGE%3A%0A%0Adraw%20%26%20simulate%0Ayour%20OWN%20mental%0Afeedback%20loops"]],7]

Thanks in advance if this gets any hits!

NapsterInBlue avatar Feb 22 '21 00:02 NapsterInBlue

I would dive into code where the URL / file get loaded in Loopy.js and I'll notice that it goes to self.model.deserialize(content); That leads me to following code in Model.js : ` self.deserialize = function(dataString){

	self.clear();

	var data = JSON.parse(dataString);

	// Get from array!
	var nodes = data[0];
	var edges = data[1];
	var labels = data[2];
	var UID = data[3];

... self.addNode(...) self.addEdge(...); self.addLabel(...)

`

That's pretty much of it.

Good luck

sefgit avatar Feb 22 '21 02:02 sefgit

I've forked loopy last year, and create 2 new storage format, one binarized and compressed for optimized character use in url and one more readable for human. And you can import the old save file in my forked version to save them in other format.

You can test it here : https://lo0p.it/2/ Find the source-code here : https://github.com/1000i100/loopy and here is what your model look like in human readable format system_model.loopy.json :

{
  "globals": {
    "loopyMode": 1,
    "colorLogic": 0,
    "cameraMode": 0
  },
  "nodes": [
    {
      "id": 0,
      "x": 198,
      "y": 285,
      "init": 0,
      "label": "depression",
      "hue": 0,
      "size": 1,
      "aggregationLatency": 0,
      "overflow": 0,
      "underflow": 1,
      "explode": 0,
      "foreignColor": 0
    },
    {
      "id": 1,
      "x": 531,
      "y": 282,
      "init": 0,
      "label": "doing things",
      "hue": 4,
      "size": 1,
      "aggregationLatency": 0,
      "overflow": 0,
      "underflow": 1,
      "explode": 0,
      "foreignColor": 0
    },
    {
      "id": 2,
      "x": 367,
      "y": 115,
      "init": 0,
      "label": "de-motivation",
      "hue": 1,
      "size": 1,
      "aggregationLatency": 0,
      "overflow": 0,
      "underflow": 1,
      "explode": 0,
      "foreignColor": 0
    },
    {
      "id": 3,
      "x": 702,
      "y": 116,
      "init": 0,
      "label": "fear of mistakes",
      "hue": 1,
      "size": 1,
      "aggregationLatency": 0,
      "overflow": 0,
      "underflow": 1,
      "explode": 0,
      "foreignColor": 0
    },
    {
      "id": 4,
      "x": 860,
      "y": 289,
      "init": 0,
      "label": "anxiety",
      "hue": 0,
      "size": 1,
      "aggregationLatency": 0,
      "overflow": 0,
      "underflow": 1,
      "explode": 0,
      "foreignColor": 0
    },
    {
      "id": 5,
      "x": 699,
      "y": 468,
      "init": 0,
      "label": "accepting mistakes",
      "hue": 4,
      "size": 1,
      "aggregationLatency": 0,
      "overflow": 0,
      "underflow": 1,
      "explode": 0,
      "foreignColor": 0
    },
    {
      "id": 6,
      "x": 364,
      "y": 473,
      "init": 0,
      "label": "feeling good",
      "hue": 4,
      "size": 1,
      "aggregationLatency": 0,
      "overflow": 0,
      "underflow": 1,
      "explode": 0,
      "foreignColor": 0
    }
  ],
  "edges": [
    {
      "from": 1,
      "to": 6,
      "arc": 59,
      "strength": 1,
      "rotation": 0,
      "signBehavior": 0,
      "edgeFilterColor": -1,
      "edgeTargetColor": -1,
      "customLabel": "",
      "quantitative": 0,
      "filter": 0
    },
    {
      "from": 1,
      "to": 5,
      "arc": -61,
      "strength": 1,
      "rotation": 0,
      "signBehavior": 0,
      "edgeFilterColor": -1,
      "edgeTargetColor": -1,
      "customLabel": "",
      "quantitative": 0,
      "filter": 0
    },
    {
      "from": 5,
      "to": 4,
      "arc": -59,
      "strength": -1,
      "rotation": 0,
      "signBehavior": 0,
      "edgeFilterColor": -1,
      "edgeTargetColor": -1,
      "customLabel": "",
      "quantitative": 0,
      "filter": 0
    },
    {
      "from": 4,
      "to": 3,
      "arc": -57,
      "strength": 1,
      "rotation": 0,
      "signBehavior": 0,
      "edgeFilterColor": -1,
      "edgeTargetColor": -1,
      "customLabel": "",
      "quantitative": 0,
      "filter": 0
    },
    {
      "from": 3,
      "to": 1,
      "arc": -53,
      "strength": -1,
      "rotation": 0,
      "signBehavior": 0,
      "edgeFilterColor": -1,
      "edgeTargetColor": -1,
      "customLabel": "",
      "quantitative": 0,
      "filter": 0
    },
    {
      "from": 2,
      "to": 1,
      "arc": 56,
      "strength": -1,
      "rotation": 0,
      "signBehavior": 0,
      "edgeFilterColor": -1,
      "edgeTargetColor": -1,
      "customLabel": "",
      "quantitative": 0,
      "filter": 0
    },
    {
      "from": 0,
      "to": 2,
      "arc": 66,
      "strength": 1,
      "rotation": 0,
      "signBehavior": 0,
      "edgeFilterColor": -1,
      "edgeTargetColor": -1,
      "customLabel": "",
      "quantitative": 0,
      "filter": 0
    },
    {
      "from": 6,
      "to": 0,
      "arc": 63,
      "strength": -1,
      "rotation": 0,
      "signBehavior": 0,
      "edgeFilterColor": -1,
      "edgeTargetColor": -1,
      "customLabel": "",
      "quantitative": 0,
      "filter": 0
    }
  ],
  "labels": [
    {
      "x": 365,
      "y": 296,
      "text": "a possible\nsystems-level\nexplanation for\nwhy depression &\nanxiety are not just\nco-morbid, but\nMUTUALLY SELF-\nREINFORCING",
      "visibility": 0,
      "textColor": -1,
      "href": ""
    },
    {
      "x": 695,
      "y": 300,
      "text": "CHALLENGE:\n\ndraw & simulate\nyour OWN mental\nfeedback loops",
      "visibility": 0,
      "textColor": -1,
      "href": ""
    }
  ]
}

does-it help you ?

1000i100 avatar Feb 22 '21 12:02 1000i100

PS : in v1.1 these parameters doesn't exist so you can ignore them :
On nodes : "size": 1, "aggregationLatency": 0, "overflow": 0, "underflow": 1, "explode": 0, "foreignColor": 0

On link/edge : "signBehavior": 0, "edgeFilterColor": -1, "edgeTargetColor": -1, "customLabel": "", "quantitative": 0, "filter": 0

On label : "visibility": 0, "textColor": -1, "href": ""

1000i100 avatar Feb 22 '21 12:02 1000i100

Commented on a year-old thread on a whim. Woke up to three insightful comments.

Busy workday ahead of me, but I'm looking forward to digging into this after, and will get back with an update on my end, or any hangups I run into!

Salt of the earth-- the whole lot of you :)

NapsterInBlue avatar Feb 22 '21 14:02 NapsterInBlue