{"id":4187,"date":"2024-11-20T10:46:42","date_gmt":"2024-11-20T09:46:42","guid":{"rendered":"https:\/\/lookingatnothing.com\/?p=4187"},"modified":"2024-11-21T19:40:53","modified_gmt":"2024-11-21T18:40:53","slug":"wip-exploring-analytical-scattering-models-interactively-with-the-sasmodels-explorer","status":"publish","type":"post","link":"https:\/\/lookingatnothing.com\/index.php\/archives\/4187","title":{"rendered":"WIP: Exploring analytical scattering models interactively with the SasModels Explorer"},"content":{"rendered":"\n<p><em>[Update: I had apparently been updating my own git repo for this project, rather than the BAMResearch one&#8230; that has now been fixed and you should be able to download a much more up-to-date version now]<\/em><\/p>\n\n\n\n<p>Another useful tool for getting users familiar with model and model combinations is this interactive tool that lets you interactively explore them with sliders and a responsive UI. I&#8217;ve been working on the <a href=\"https:\/\/github.com\/BAMresearch\/SasModelsExplorer\">SasModels Explorer<\/a> for a bit to do just this. Read on for some pretty screenshots and more&#8230;<\/p>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.43.56.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"469\" src=\"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.43.56-1024x469.png\" alt=\"\" class=\"wp-image-4193\" srcset=\"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.43.56-1024x469.png 1024w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.43.56-300x137.png 300w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.43.56-768x352.png 768w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.43.56.png 1085w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Figure 0: playing around with a complex model in the SasModels Explorer.<\/figcaption><\/figure>\n\n\n\n<p>The <a href=\"https:\/\/github.com\/SasView\/sasmodels\">SasModels library<\/a> is the cornerstone of the expansive SasView fitting tool. As the name suggests, the SasModels library contains the <a href=\"https:\/\/www.sasview.org\/docs\/user\/qtgui\/Perspectives\/Fitting\/models\/index.html\">analytical models for many shapes and functions<\/a>, such as &#8220;sphere&#8221;, &#8220;cylinder&#8221;, the Debye-Anderson-Brumberger &#8220;dab&#8221; and &#8220;porod&#8221; models, in addition to structure factors such as &#8220;hardsphere&#8221;. but also allows easy composition of these into more complex models. <\/p>\n\n\n\n<p>That means you can add, multiply, divide and subtract model combinations, and apply structure factors as well. So by writing &#8220;sphere@hardsphere+cylinder+porod&#8221;, you get a combined model with all these features (the parameters will be preceded by a letter and underscore, e.g. &#8220;A_&#8221; for the first component). <\/p>\n\n\n\n<p>Making and exploring composite models in <a href=\"https:\/\/www.sasview.org\">SasView<\/a>, however, is a bit of a tedious process (<a href=\"https:\/\/sasfit.org\">SASfit<\/a> has a comparatively easier way of doing this). On top of that, exploring how model parameters affect the model scattering curve involves entering values in text boxes and clicking &#8220;calculate&#8221; for every change. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/SME.gif\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"400\" src=\"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/SME.gif\" alt=\"\" class=\"wp-image-4190\"\/><\/a><figcaption class=\"wp-element-caption\">Figure 1: Playing around with the interface&#8230;<\/figcaption><\/figure>\n\n\n\n<p>So I wrote the <a href=\"https:\/\/github.com\/BAMresearch\/SasModelsExplorer\">SasModels Explorer<\/a> as an easy way of creating and interacting with models. It&#8217;s a simple QT5-based UI that can be started from the command line. You can specify a model on the command line already to start with (but this can be changed later in the UI). A UI is launched with a graph on the right-hand side, and the model and its parameters on the left-hand side. log-sliders are added to the floating point parameters, and pulldown menus for parameters with a list of options. Dragging on the log sliders immediately affects the model curve, at least for the simpler models. <\/p>\n\n\n\n<p>Typing a new model or model combination in the model entry textbox lets you explore new ones (if your model name can&#8217;t be found, a list is shown with the available models). At the moment, there&#8217;s still a small bug in the UI which does not clean up the previous parameter interface completely, and therefore shifts the new parameter inputs down a bit, but that&#8217;s only a minor annoyance. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.27.26.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"468\" src=\"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.27.26-1024x468.png\" alt=\"\" class=\"wp-image-4191\" srcset=\"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.27.26-1024x468.png 1024w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.27.26-300x137.png 300w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.27.26-768x351.png 768w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.27.26.png 1087w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Figure 2: A gap appears when changing the model in the interface. Note that the scaling on Porod and dab need significant reduction to avoid dominating the model intensity. <\/figcaption><\/figure>\n\n\n\n<p>A second caveat is that there is no way to stop slow calculations. If you decide to set up a complex model with, for example, many numerical integrations, this will slow the interface down to the point it&#8217;s no longer usable. Thirdly, the log sliders all max out at 1000 at the moment, which may occasionally be limiting. <\/p>\n\n\n\n<p>Nonetheless, the interface is fun to use, and I recommend those who want to play to download it and have a go at it. Please let me know if you use this in a classroom or something, so I can feel good about the time spent on its development. Also, if you have improvements or suggestions, please do not hesitate to contribute them in a <a href=\"https:\/\/github.com\/BAMresearch\/SasModelsExplorer\">pull request or add them to the GitHub issue list<\/a>. <\/p>\n\n\n\n<p>The final hope is that this UI can be included as a tool in SasView, or perhaps inspire alternative methods for model building, initial parameter setting, or even a simple fitting interface. Given its modular nature and QT backend, that is hopefully not too far off the realm. <\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>[Update: I had apparently been updating my own git repo for this project, rather than the BAMResearch one&#8230; that has now been fixed and you <a class=\"mh-excerpt-more\" href=\"https:\/\/lookingatnothing.com\/index.php\/archives\/4187\" title=\"WIP: Exploring analytical scattering models interactively with the SasModels Explorer\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":2,"featured_media":4193,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"federate","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-4187","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2024\/11\/Screenshot-2024-11-20-at-10.43.56.png","jetpack_shortlink":"https:\/\/wp.me\/p1gZ2v-15x","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/posts\/4187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/comments?post=4187"}],"version-history":[{"count":5,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/posts\/4187\/revisions"}],"predecessor-version":[{"id":4197,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/posts\/4187\/revisions\/4197"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/media\/4193"}],"wp:attachment":[{"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/media?parent=4187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/categories?post=4187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/tags?post=4187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}