PixInsight Forum (historical)
Software Development => New Scripts and Modules => Topic started by: bitli on 2012 April 07 06:40:40
-
VaryParams executes a process varying a parameter (see attached image). It can save the results to files (for example for use by Blink) or as previews.
This is mostly useful with process modifying the source view or generating a single view (as ACDNR, StarMask, ...).
Process as DBE should be configured to update the source view (the original view will not be modified, this
will be done on a copy).
To use it, download the zip file, create a process icon, select the view and execute VaryParams.js
REQUIRES THE VERSION 1.7.6.793 (at least)
[EDITED (Jan 5, 2013)
Version-1.2 attached (combined script in 1 file)
The full project sources is hosted at https://bitbucket.org/bitli/varyparams
]
Have a nice week-end,
-- bitli
-
good idea!
-
Whoa, this changes everything! :D
I agree, this is a great idea and could provide a way to systematically and carefully proceed with each step of processing. If used in conjunction with image analysis tools, one could optimize a path to a 'best' image given a specific set of data (artistic considerations aside).
-
Hello,
Version 0.2 has been attached to the first topic. It has significant enhancements. It works much better with processes generating multiple windows, support array parameters, copy masks when required, save and restore settings and generate a log of the results.
The sources include a few test scripts that are not required for normal operations. They may be executed in a test workspace. The test workspace with the sources is also available at http://endor.uv.es//data/public/d2aacbf623f007952a19e598d550a959.php?lang=en (due to size constraints).
Here is the log of an example runnning an Integration varying the parameter linearFitHigh:
Generated 4 files in C:/Users/bitli/AppData/Local/Temp:
# linearFitHigh - file
1: 1.5 - C:/Users/bitli/AppData/Local/Temp/integration_1.fits
- C:/Users/bitli/AppData/Local/Temp/rejection_low_1.fits
- C:/Users/bitli/AppData/Local/Temp/rejection_high_1.fits
2: 2 - C:/Users/bitli/AppData/Local/Temp/integration_2.fits
- C:/Users/bitli/AppData/Local/Temp/rejection_low_2.fits
- C:/Users/bitli/AppData/Local/Temp/rejection_high_2.fits
3: 2.5 - C:/Users/bitli/AppData/Local/Temp/integration_3.fits
- C:/Users/bitli/AppData/Local/Temp/rejection_low_3.fits
- C:/Users/bitli/AppData/Local/Temp/rejection_high_3.fits
4: 3 - C:/Users/bitli/AppData/Local/Temp/integration_4.fits
- C:/Users/bitli/AppData/Local/Temp/rejection_low_4.fits
- C:/Users/bitli/AppData/Local/Temp/rejection_high_4.fits
You may load them in Blink from the directory 'C:/Users/bitli/AppData/Local/Temp'
-- bitli
-
The version 1.0 has been posted in the first message of this thread.
It has minor enhancements and some bug corrections.
It is now distributed as a single source file, so it is simpler to install.
All the source files, test files and test projects are available at https://bitbucket.org/bitli/varyparams.
Clear skies
-- bitli
-
GREAT IDEA !! Will be a good combination with eg a deconvolution process ;)
-
MERCIIIIIIIIIII !!
It is what you saw me in May at Besançon 8)
-
Thanks Bitli!
A great idea and help!
Gerald
-
Hmm, I tried it today without success. I tried to run LocalHistorgramEqualization on a View, I saved the process on the desktop, opened the script and configured it as per the attached. The results are below (BTW what ACDNR has to do with it ? ) :
processTypeDescription
name: ACDNR
unsupported: false
mayExecuteGlobally: true
mayExecuteOnView: true
mayUpdateSource: true
mayCreateNewWindow: true
Execute process 'Process02' on view : LRGB_clone not masked, with parameter: amount = 0.5
LocalHistogramEqualization: Processing view: LRGB_clone
Writing swap files...
166.07 MB/s
Extracting CIE L* component: 100%
CLAHE: 100%
Importing CIE L* component: 100%
168.9 s
Writing swap files...
176.45 MB/s
Reading swap files...
752.86 MB/s
ERROR: This process modifies the source window, please select 'Update source image' in process mode, modifications undone
** VaryParams: Interrupting execution 1 due to error in last process, look at the log.
VaryParams terminated
-
Hello,
I tried on my machine with one difference and it worked (although I do not know why it logs ACDNR as the process name, I need to check, this may be a bug). The result is like:
Generated 2 windows from view light_BINNING_1 with main views:
# amount - window main view
1: 0.5 - light_BINNING_1_Process01_1
2: 1 - light_BINNING_1_Process01_2
The trick is to select Update source image in the field Type of process.
I guess the label is not clear. The type of the process is not what you want to do (create new images), but what the process is doing. LocalHistorgramEqualization is a process that updates the image, in opposition of to say StarMask that creates a new image. VaryParams does not know if the process will modify the image or update in place (it needs to know to make the copies at the proper stage).
In all cases VaryParam will not modify the source image. If it detects that the process modified the image, it reverts the modification and log the message you have seen:
ERROR: This process modifies the source window, please select 'Update source image' in process mode, modifications undone
If you try again with the setting mentionned it should work. If not inform me.
Greetings
-- bitli
-
VaryParams does not know if the process will modify the image or update in place (it needs to know to make the copies at the proper stage).
You can know that in advance. The following method of the ProcessInstance object:
Boolean ProcessInstance.isHistoryUpdater( View view )
returns true if the instance will modify the specified view when executed. You can call this method before calling executeOn( view ) to decide if a working duplicate is necessary.
By the way, this script is very nice and original. As soon as I have some time I'd like to try it out. Do you think it is ready for the 1.8 release (end of September - beginning of October)? Keep up the great work!
-
I start to thing that having you answering the questions is more convenient than reading documentation ;)
Very useful information, I added the isHistorySelector and it seems that there is a single choice in the few processes I checked. This will remove the most confusing aspect of the script. I will complete this for the next version.
I have added the PI open source copyright, feel free to use it as you see fit. I have used it for a while with no major problem. Some processes crash if you give them totally wrong values (I guess they hope that the GUI validated the values), but in practice this does not happen for the parameters I use.
The full source is at https://bitbucket.org/bitli/varyparams (https://bitbucket.org/bitli/varyparams). The page has a 'zip' download link, so you can easily download the whole project without installing Mercurial. The projects includes alo test scripts, a small test workspace and the script to create the release. You can load the workspace and execute the automatic test script, that should give you a good confidence that it works on 1.8 (or not). In my opinion it should be ready, but it would be nice if some user can tests it and provide feedback.
-- bitli
-
Tested as you said and it works.
Sure Juan's addition will make it more clear (you will be amazed how much information this man can pass from a single question ;) )
BTW, ACDNR is in line 229:
new Vp_ProcessTypeDescription("ACDNR")
and a suggestion, please give new Views a more descriptive Title, eg instead of my_LRGB_Process01, my_LRGB_Process01_1, my_LRGB_Process01_2 etc, how about my_LRGB_Process01_Amount05, my_LRGB_Process01_Amount06, my_LRGB_Process01_Amount07, ie put the parameter name and the parameter value in the Title ? (or maybe in the filename ?)
-
Thanks,
Yes the lines with ACDNR are completly wrong, it is a left over on an old stuff. I will remove this. The selection of 'process type' will be removed. I also have an help page in the next version.
Finally your idea of giving a more meaningful name is very good. I had the same :). It is just a little bit more complicated that it looks, because the parameters must form a valid file name and PI id and the ids must be unique. For the time being I tried to make a nice table printed on the console so you can match the value and the image relatively easily.
But I will think of this again and try to come to a way to rename the images/files.
-- bitli
-
Version 1.1 has been attached to the first post.
The main enhancement is hat it guesses the type of the process itself.
It also includes a HELP page and show the source view on top of the dialog.
Currently it does not support processes that only create new images as files, as CosmeticCorrection.
-- bitli
-
Working like a charm. I'm finding myself using more and more this script, once again thank you.
(btw , I did not tested, is it working with a process container ? >:D )
-
Thanks for the comment,
Unfortunately it does not work for ProcessContainer (this might be possible but requires quite some work, not sure I will have the time to do it). Also it does not work with scripts (this is currently a limitation of PI) or with process that only generate files (as CosmeticCorrection). For this type of process I would need to find the outputDirectory and possibly prefix/postfix to adapt them between each run, unfortunately the names of theses properties is not standarized (I could probably find them in the most common cases - when I have the time).
-- bitli
-
Thank you. Actually I was joking for the process container. I'm fully aware of the issues involved.
-
Would someone kindly point me to instructions for using the *.js file as a script? Senior moment.
Dave
-
dave, you can just go Script > Execute Script File... and point the file explorer at the .js you downloaded.
-
Thanks. I should have remembered that!
Dave
-
You can also add it to the the PI script directory (C:\Program Files\PixInsight\src\scripts on windows), and use the menu Script / Feature Scripts and then Add or Regenerate (can't remember which one, I hit buttons until I see that the script was added).
Then the script shows under Script / Utilities like the built in scripts.
-- bitli
-
Thanks, bitli.
Dave
-
Version 1.2 has been attached to the first post.
Minor corrections in some error handling and made compatible with PI 1.8 (parameters do not work on RC1, but should work on RC2). There is no need to update if you are still using PI 1.7.
-- bitli