{"action":"created","issue":{"url":"https://api.github.com/repos/bastibe/transplant/issues/13","repository_url":"https://api.github.com/repos/bastibe/transplant","labels_url":"https://api.github.com/repos/bastibe/transplant/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/bastibe/transplant/issues/13/comments","events_url":"https://api.github.com/repos/bastibe/transplant/issues/13/events","html_url":"https://github.com/bastibe/transplant/issues/13","id":161131120,"number":13,"title":"Performance on windows","user":{"login":"YoelShoshan","id":7043815,"avatar_url":"https://avatars.githubusercontent.com/u/7043815?v=3","gravatar_id":"","url":"https://api.github.com/users/YoelShoshan","html_url":"https://github.com/YoelShoshan","followers_url":"https://api.github.com/users/YoelShoshan/followers","following_url":"https://api.github.com/users/YoelShoshan/following{/other_user}","gists_url":"https://api.github.com/users/YoelShoshan/gists{/gist_id}","starred_url":"https://api.github.com/users/YoelShoshan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YoelShoshan/subscriptions","organizations_url":"https://api.github.com/users/YoelShoshan/orgs","repos_url":"https://api.github.com/users/YoelShoshan/repos","events_url":"https://api.github.com/users/YoelShoshan/events{/privacy}","received_events_url":"https://api.github.com/users/YoelShoshan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-06-20T07:19:41Z","updated_at":"2016-06-20T14:41:53Z","closed_at":null,"body":"I'll start by saying that as you've discovered, matlab.engine is practically not usable for me, due to their massive memory leaks.\r\n\r\nNote: I'm using Matlab 2014b\r\n\r\nHowever, unlike what you found on linux, on windows it seems that transplant is much slower than matlab.engine, at least in certain operations.\r\n\r\nI can't provide a fully reproducable scenario, but here are the main relevant functions:\r\n\r\n```\r\nimport transplant\r\nmatlab = transplant.Matlab()\r\n...\r\ndef load_mat_TRANSPLANT(filename,verbose=False):\r\n    matlab.evalin('base', 'my_obj = load(\\'{0}\\');'.format(filename))\r\n    matlab.evalin('base', 't1 = my_obj.study.series_index.type.T1_dynamic_contrast;')\r\n    if verbose:\r\n        print('T1_dynamic_contrast serieses:',matlab.t1)\r\n\r\n    t1_dyn_con_volumes = list(map(int,matlab.t1[0]))\r\n\r\n    volumes = []\r\n\r\n    for v in t1_dyn_con_volumes:\r\n        matlab.evalin('base', 'my_vol = my_obj.study.series{{{0}}}.image;'.format(t1_dyn_con_volumes[0]))\r\n        if verbose:\r\n            print('volume shape:', matlab.my_vol.shape)\r\n        #plt.imshow(matlab.my_vol[:, :, 30])\r\n\r\n        volumes.append(matlab.my_vol)\r\n\r\n\r\n    return volumes\r\n```\r\n\r\nAnd here's the code using matlab.engine (it's a bit different, I actually do MORE there...)\r\n\r\n```\r\ndef load_mat_MATLAB_ENGINE(filename,verbose=False):\r\n    cmd_text = 'load(\\'{0}\\');'.format(filename)\r\n    my_obj = eng.eval(cmd_text)\r\n\r\n    eng.workspace['my_obj'] = my_obj\r\n\r\n    t1 = eng.eval('my_obj.study.series_index.type.T1_dynamic_contrast;')\r\n\r\n    if verbose:\r\n        print('T1_dynamic_contrast serieses:',t1)\r\n\r\n    t1_dyn_con_volumes = list(map(int,t1[0]))\r\n\r\n    volumes = []\r\n\r\n    for v in t1_dyn_con_volumes:\r\n        my_vol = eng.eval('my_obj.study.series{{{0}}}.image;'.format(t1_dyn_con_volumes[0]))\r\n        arr = np.array(my_vol._data).reshape((my_vol.size[2], my_vol.size[0], my_vol.size[1]), order='C')\r\n        arr = np.swapaxes(arr,1,2)\r\n\r\n        if verbose:\r\n            print('volume shape:', arr.shape)\r\n\r\n        volumes.append(arr)\r\n    return volumes\r\n```\r\n\r\nEach .mat file may contain few volumes.\r\n\r\nHere's the comparison run times\r\n*filename* *matlab_engine_seconds* *transplant_seconds*\r\nmat_file_1  5.4  18.3\r\nmat_file_2  30.8  75.3\r\nmat_file_3  36.3 174.2\r\n\r\nIf possible, please test your library on windows passing around big volumes and say if you see the same performance issue.\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/bastibe/transplant/issues/comments/227162438","html_url":"https://github.com/bastibe/transplant/issues/13#issuecomment-227162438","issue_url":"https://api.github.com/repos/bastibe/transplant/issues/13","id":227162438,"user":{"login":"bastibe","id":649181,"avatar_url":"https://avatars.githubusercontent.com/u/649181?v=3","gravatar_id":"","url":"https://api.github.com/users/bastibe","html_url":"https://github.com/bastibe","followers_url":"https://api.github.com/users/bastibe/followers","following_url":"https://api.github.com/users/bastibe/following{/other_user}","gists_url":"https://api.github.com/users/bastibe/gists{/gist_id}","starred_url":"https://api.github.com/users/bastibe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bastibe/subscriptions","organizations_url":"https://api.github.com/users/bastibe/orgs","repos_url":"https://api.github.com/users/bastibe/repos","events_url":"https://api.github.com/users/bastibe/events{/privacy}","received_events_url":"https://api.github.com/users/bastibe/received_events","type":"User","site_admin":false},"created_at":"2016-06-20T14:41:53Z","updated_at":"2016-06-20T14:41:53Z","body":"It seems that base64 encoding is very slow. I think I can solve this."}}
{"actor":{"display_login":"bastibe"}}