In ImageJ, I can open a series of images (tif, png, jpg, etc.) as a stack by using File>>Import>>Image Sequence...
And I can open a text image (.txt file containing a matrix of pixels) using File>>Import>>Text Image...
But how can I open a series of text images as a stack?
Some people have offered a Macro that does this, but it does not work very well, because it also opens all of the images individually and, if you have other images open, then those are incorporated into the stack as well (try running the macro twice in a row).
It would be nice if there was a macro or plugin that would import the text images into a single stack (ignoring other open images) and not also bring up the individual images. Basically, it should operate just like Import>>Image Sequence.
Here is the current macro as a starting point, though I'm not sure this is the best place to start. Thanks!
dir = getDirectory("Choose directory");
list = getFileList(dir);
run("Close All");
setBatchMode(true);
for (i=0; i<list.length; i++) {
file = dir + list[i];
run("Text Image... ", "open=&file");
}
run("Images to Stack", "use");
setBatchMode(false);
Personally the macro you pasted worked for me when run in the latest Fiji - the run("Close All"); line is intended to prevent unintended images from being included in your stack, while the batch mode prevents the intermittent images from popping up.
In fact Images to Stack is supposed to complain if you try to run it with a non-2D image (i.e. the output of your previous run). So if you are seeing this behavior when running the macro, it could be a bug - can you provide more information about what version of ImageJ/OS/Java you're using?
Also, a more general solution may be the Bio-Formats importer - which has a flag that allows you to group multiple files into a single stack. If you don't want to manually install it, Bio-Formats is included by default with the Fiji distribution of ImageJ
You may also be interested in testing ImageJ2 functionality, which is intended to slot in full format support into existing functions - e.g. so that macros like this do not need to be tailored to individual formats. In theory, if you download Fiji and turn on Edit>Options>ImageJ2, then File>>Import>>Image Sequence... should simply work the way you wanted it to... but it's currently not well tested.
If you want to avoid closing other open images, you can use the Title Contains parameter of Images to Stack:
Just rename the opened text images so that their title contains a unique string.
Use the Macro recorder to get the corresponding macro code:
dir = getDirectory("Choose directory");
list = getFileList(dir);
setBatchMode(true);
for (i=0; i<list.length; i++) {
file = dir + list[i];
run("Text Image... ", "open=[" + file + "]");
rename("myUniqueIdentifier" + file);
}
run("Images to Stack", "title=myUniqueIdentifier");
setBatchMode(false);
Related
So I just started using Neovim/Spacevim, and it's so awesome!
I am still getting used to everything, since I have never used Vim or anything like that before.
My question revolves around searching for particular text in all the files of the currently open project.
I am using the nerdtree file manager, and I was wondering how I might search through all the files in the project for a specific string. Like if I wanted to search function thisExactFunction() throughout the currently open folder/directory, how would I go about doing that? The main goal is to have a list of all the files that contain this search string.
I have fzf installed (as well as ripgrep), but seem to be having trouble in searching for specific text inside of all files. I can only search for files themselves, or some other search that does not yield what I need.
Can anyone point me in the right direction...? Thanks!
Check out the Ggrep command that Fzf supplies - see this series of vim screencasts to see how to use vim's in built features (quickfix list populated by :vimgrep) to achieve the same using other grepping tools.
Custom functions
I have a function in my .vimrc that uses ag silver
searcher to search within all
the files in a directory (and any subdirectories). So if you install ag, this
should work:
" Ag: Start ag in the specified directory e.g. :Ag ~/foo
function! s:ag_in(bang, ...)
if !isdirectory(a:1)
throw 'not a valid directory: ' .. a:1
endif
" Press `?' to enable preview window.
call fzf#vim#ag(join(a:000[1:], ' '),
\ fzf#vim#with_preview({'dir': a:1}, 'right:50%', '?'), a:bang)
endfunction
" Ag call a modified version of Ag where first arg is directory to search
command! -bang -nargs=+ -complete=dir Ag call s:ag_in(<bang>0, <f-args>)
Bonus
Sometimes it's hard to find things in vim's help, so I also have a function
that uses the one above to interactively search the help docs. This can be nice
to hone in on the topic you want. Use :H for this function (as opposed to the
classic :h)
function! Help_AG()
let orig_file = expand(#%)
let v1 = v:version[0]
let v2 = v:version[2]
" search in the help docs with ag-silver-search and fzf and open file
execute "normal! :Ag /usr/share/vim/vim".v1.v2."/doc/\<CR>"
" if we opened a help doc
if orig_file != expand(#%)
set nomodifiable
" for some reason not all the tags work unless I open the 'real' help
" so get whichever help was found and open it through Ag
let help_doc=expand("%:t")
" open and close that help doc - now the tags will work
execute "normal! :tab :help " help_doc "\<CR>:q\<CR>"
endif
endfunction
" get some help
command! H :call Help_AG()
I want to include an example of my model code within my project report. I have tried taking a screenshot of my code but it is just too long to be legible. I am therefore wondering if it is possible to output an image of my model code that has not been minimised or cut up into a word document for annotation?
(I assume the reason you don't just copy and paste is that you want to preserve the colors?)
Use “Save as Applet” on the File menu. From the resulting HTML file, cut out the applet part and just keep the code part.
Direct support for "Save as HTML" is coming in NetLogo 6.0; see https://github.com/NetLogo/NetLogo/issues/645.
If Seth guessed wrong and you just need a monospace font, you can just copy (ctrl-A,ctrl-C) in the Code tab, paste into your Word document, and set the font to any monospace font (like Courier New).
If Seth guessed correctly and you want syntax highlighting, you can get the Vim syntax file, open your NetLogo file in Vim, select the code range, and then use Vim's TOhtml command. You can then read this HTML file into your Word document.
Note that using Word for reports involving code is a terrible idea: the code will immediately be out of sync, as soon as you make further changes. Instead, learn LaTeX use the listings package to read your code into your document.
Is there a way to tell org-mode to load only the first N lines of a long text file? I would like to keep the whole file open to be able to search through it, but have org-mode display on the first N lines of my file, which is where I edit new content.
If you have a structured outline in org-mode, you can set the global file visibility with the #+STARTUP markup, or the visibility of any heading with the VISIBILITY property, see Visibility Cycling for details. The benefit of using the built-in org-mode properties is that it's easy to have a file open up in exactly the state you want.
I have my journal file set up to accomplish something similar what I think you're asking for using these org-mode properties. The "Today" section is opened so I can see everything, but older archives are collapsed.
I'm not sure the title really fits the description?
I think you just want use buffer narrowing, which lets you hide everything outside of the specified region for as long as necessary.
You can manually narrow the buffer by marking the region and typing C-xnn
Widen the display back to the full buffer with C-xnw
I guess you could use an eval Local Variable to automate this to a pre-defined region, if you really wanted to.
There's also narrow-to-defun (C-xnd) and narrow-to-page (C-xnp). If you throw a page break into your org file (C-qC-l), the latter might prove handy.
Right now I am using the prompt command as a workaround to copy arbitrary text out of my JSX script in Photoshop.
prompt("to copy",(horizontalcenter.toString()) + ", " + verticalcenter.toString());
And that is giving me the information that I want. The "to copy" just gives the title, then the information I want to copy out of Photoshop is in the prompt box already selected. So all I have to do is hit control C, go to Notepad++ where I need this information, and hit control V.
It works, but it could be faster. There has to be a way to copy this information out of Photoshop straight to the clipboard, no?
Photoshop 13.1 (the latest Creative Cloud release of Photoshop CS6) now has a hook allowing you to do this directly. Here's a sample function:
function copyTextToClipboard( txt )
{
const keyTextData = app.charIDToTypeID('TxtD');
const ktextToClipboardStr = app.stringIDToTypeID( "textToClipboard" );
var textStrDesc = new ActionDescriptor();
textStrDesc.putString( keyTextData, txt );
executeAction( ktextToClipboardStr, textStrDesc, DialogModes.NO );
}
Please note this won't work in versions of Photoshop prior to 13.1
Found the answer on a Photoshop scripting forum.
http://ps-scripts.com/bb/viewtopic.php?f=9&t=3097&p=15324&hilit=clipboard&sid=1b1cc023023b9f91ab46e30e48e2ab53#p15324
function copyTextToClipboard(text)
{
var folderForTempFiles = Folder.temp.fsName;
// create a new textfile and put the text into it
var clipTxtFile =new File(folderForTempFiles + "/ClipBoard.txt");
clipTxtFile.open('w');
clipTxtFile.write(text);
clipTxtFile.close();
// use the clip.exe to copy the contents of the textfile to the windows clipboard
var clipBatFile =new File(folderForTempFiles + "/ClipBoard.bat");
clipBatFile.open('w');
clipBatFile.writeln("cat \"" + folderForTempFiles + "/ClipBoard.txt\"|clip");
clipBatFile.close();
clipBatFile.execute();
}
It's placing the text you want to copy in a temp text file, then copying it from that text file. I didn't even know you could place text into a text file. Apparently the javascript capabilities in Photoshop are much more powerful than I realized!
I would like to accomplish two tasks at once.
First, to move my snippets of code from .txt files and be able to tag them/organize better.
Second, assign shortcuts to those snippets that will allow me to type "p" + TAB which will render assigned snippet (I don't care of cursor position etc)
Quick Importing - resources
You can do a brief CTRL + SHIFT + R. This will enable you to display any kind of file from inside your projects directory.
To open any resource type * . *
To select resource to open type ?
To open all text files type *.txt
Snippets - templates
Eclipse has auto fill property. You can enhance it using templates. There are many ready-to-use templates, and you can even create your own.
Templates are used by typing the first character and pressing CTRL + SPACE.
Organize code - formating & tags
If you want to organize you code even more, you can use existing tags like TODO or create your own tags. Use them to sort or prioritize the code snippets you want to import into another project.
You can use CTRL + SHIFT + F to reformat your code.